Skip to main content

๐Ÿ“ฉ Transfer Tokens

๐Ÿšจ Read Before ๐Ÿšจโ€‹

Create Transactionโ€‹

from lunespy.tx.transfer import transfer_token_factory
from lunespy.wallet import wallet_factory

sender = wallet_factory()

tx = transfer_token_factory(
sender_public_key=sender.public_key,
receiver_address="37sEXsHBBUagA3jmzHPz1ZGA3vDtCLUNs5Z",
amount=249.99
)

Sign Transactionโ€‹

tx.sign(sender.private_key)

Broadcast Transactionโ€‹

tx.broadcast()

Full Exampleโ€‹

from lunespy.tx.transfer import transfer_token_factory
from lunespy.wallet import wallet_factory

sender = wallet_factory()

tx = transfer_token_factory(
# public key of sender
sender_public_key=sender.public_key,
# address that will receiver tokens
receiver_address="37sEXsHBBUagA3jmzHPz1ZGA3vDtCLUNs5Z",
# amount of tokens to send
amount=249.99,
# omit if you want to send lunes, pass only if you want to send some token
assetId="E3ZpxkM2kvS78aFYG2xFfngchMgik4ogLLRa6CBJvVgz",
# if you want to send a different fee amount, the default is 100000 (0.01 Lunes)
fee=100000,
# to which chain the transaction should be mounted, the defaul is 1 (MAINNET)
# should be passed 0 for works in TESTNET
chain=0
)

tx.sign(
# private key of sender for sign the transaction
sender.private_key
)

tx.broadcast(
# url or ip:port of the node that will broadcast the transaction,
# (MAINNET) is https://lunesnode.lunes.io (defaul)
# (TESTNET) https://lunesnode-testnet.lunes.io
node = "https://my-full-node.com"
)