How can I send an asset with a transaction and verify it gets sent?

You can forward coins to a contract using call_params(). The call parameter options are:

  1. Amount
  2. Asset ID
  3. Gas forwarded
// Bytes representation of the asset ID of the base asset used for gas fees.
const BASE_ASSET_ID: AssetId = AssetId::new([0u8; 32]);

// call params to send the base asset
let call_params = CallParameters::new(Some(price), Some(BASE_ASSET_ID), None);

// call send_tokens method from wallet_1
let _resp = instance
.with_wallet(wallet_1.clone())
.unwrap()
.methods()
.send_tokens()
.call_params(call_params)
.call()
.await
.unwrap();

// check the balance of wallet_1 to verify the amount was sent
let balance_1: u64 = wallet_1.get_asset_balance(&BASE_ASSET_ID).await.unwrap();
2 Likes

FUEL TO THE MOON take

You are ahead of my question. Special thanks to you for this

3 Likes