-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
47 lines (40 loc) · 1.77 KB
/
example.py
File metadata and controls
47 lines (40 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from meshtrade.type.v1 import Amount, Decimal, Ledger, Token
from meshtrade.wallet.transfer.v1 import (
CreateTransferRequest,
Transfer,
TransferService,
)
def main():
# Default configuration is used and credentials come from MESH_API_CREDENTIALS
# environment variable or default discovery methods. Zero config required
# unless you want custom configuration.
service = TransferService()
with service:
# Create request with transfer details
request = CreateTransferRequest(
transfer=Transfer(
owner=service.group(), # Current group from service context
from_="GBZH4LMGAYUDNFPNFGOBKU76DDRJHIAKGKGO2LNZFLQB6DMKV7EYHT", # Source ledger address
to="GCWNBLOHV5DKRG5UXKMO5IDAJLVSRRPGZJ5REWQPCT2LGXVQZQGWE3F", # Destination ledger address
amount=Amount(
token=Token(
code="USDC",
issuer="GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
ledger=Ledger.LEDGER_STELLAR,
),
value=Decimal(value="100.50"),
),
description="Payment for invoice #1234", # Optional reason for the transfer
include_in_ledger=True, # Include description in on-chain transaction
)
)
# Call the CreateTransfer method
transfer = service.create_transfer(request)
# Transfer has been created and submitted on-chain
print("Transfer created successfully:")
print(f" Name: {transfer.name}")
print(f" Number: {transfer.number}")
print(f" State: {transfer.state}")
print(f" Fee: {transfer.fee.amount.value}")
if __name__ == "__main__":
main()