Skip to main content

Send NFTs

After you have minted an NFT, you can easily send it by calling the Account.send_nft(addresses_nft_ids, 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_nft(addresses_nft_ids, options) function.
Dotenv

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

wallet/examples/08_send_nft.rs
loading...

Run the example by running the following command:

cargo run --example send_nft --release

Expected Output

Transaction: 0x4d3e01a0cf6d25e80af5ed774f0f741a476709a5517c21555e2c0351dda81f77
Block sent: http://localhost:14265/api/core/v2/blocks/0x7ad6ce0789ea5b5340b7045a13947af95737b3728410cdde8362021ac57f3731