Send Native Tokens
After you have created a
native token,
you can easily send it by calling the Account.send_native_tokens(params, options)
function.
As with any output, you can set output unlock conditions. Keep in mind that if you set unlock conditions, whoever you send the native tokens to may need to claim them.
Example Code
- Rust
- Typescript (Node.js)
- Python
- Instantiate a
Wallet
, get Alice'sAccount
which was created in the first guide and sync it. - Search the account's balance for a native token with a balance of at least
SEND_NATIVE_TOKEN_AMOUNT
.
- Prepare the outputs for the transaction by creating a new
SendNativeTokensParams
.
- Send the native tokens by calling the
account.send_native_tokens()
function.
- Instantiate a
Wallet
, get Alice'sAccount
which was created in the first guide and sync it. - Search the account's balance for a native token with a balance of at least
SEND_NATIVE_TOKEN_AMOUNT
.
- Prepare the outputs for the transaction by creating a new
SendNativeTokensParams
.
- Create the transaction that will send the tokens using the
Account.sendNativeTokens()
function,
Instantiate a
Wallet
, get Alice'sAccount
which was created in the first guide and sync it.Search the account's balance for a native token with a balance of at least 10.
- Define the outputs for the transaction that will send the tokens by creating the
SendNativeTokensParams
.
- Send the outputs from the previous step using the
Account.send_native_tokens()
function.
Full Example Code
- Rust
- Typescript (Node.js)
- Python
sdk/examples/how_tos/native_tokens/send.rs
loading...
bindings/nodejs/examples/how_tos/native_tokens/send.ts
loading...
bindings/python/examples/how_tos/native_tokens/send.py
loading...
Expected Output
Balance before sending: 50
Transaction sent: 0x9a1ea93962b5d4ba3a27053f4727dcc95b29ee35dc85c43d9d6be4635ab10463
Block included: https://explorer.shimmer.network/testnet/block/0xb22cba455a3176ef62352f907b0fc5e5e49b4797563826141f8057cfa960a640
Balance after sending: 40