Skip to main content

Send Native Tokens

After you have minted a native tokens, you can easily send it by calling the Account.send_native_tokens(addresses_native_tokens, options) function.

As with any output, you can set a storage deposit and output unlock conditions. Keep in mind that if you set unlock conditions, whoever you send the native tokens to may need to claim them.

Code Example

Replace the native token ID

Before you run the code example, make sure to update the token ID with one which is available in your account. If you haven't done so already, you can follow the how to mint a native token guide. If you don't know the token ID you can check your accounts balance to retrieve the available native tokens in your account.

The following example will:

  1. Create an account manager.
  2. Get Alice's account which was created in the first guide.
  3. Define the type of native token and amount to send.
  4. Send the native tokens calling the Account.send_native_tokens(addresses_native_tokens, options) function.
Dotenv

This example uses dotenv, which is not safe for use in production environments.

wallet/examples/07_send_native_tokens.rs
loading...

Run the example by running the following command:

cargo run --example send_native_tokens --release

Expected Output

Transaction: 0x649987dd056ac5ad87adb5dbfa2648262856f2dfcd0ac7039e520fc6ccbc2b1f
Block sent: http://localhost:14265/api/core/v2/blocks/0x1e2126e848f10cf2c77d122f3bd003454267c1f46c20f4a3458b74f5639ce818