How to get base asset in Rust SDK?

How to get base asset using Rust SDK??

async fn test_harness() {
    // Test code here
    let (instance, _id,wallets) = get_contract_instance().await;
    let wallet_1 = wallets.get(0).unwrap();
    let result= instance.methods().deposit().add_custom_asset(
    let result2 = instance.methods().test_deposit_asset_id_same_generated().call().await.unwrap().value;
    assert_eq!(result, result2);


This is the error:

error[E0599]: no function or associated item named `base` found for struct `fuels::types::AssetId` in the current scope
   --> tests/
12  |         AssetId::base(),
    |                  ^^^^ function or associated item not found in `AssetId`

If the function is payable:

    fn deposit() -> b256 {

        let owner = msg_sender().unwrap();
        let asset_id = msg_asset_id().bits();
        let address_from_b256: Address = Address::from(asset_id);

Do you just call it with the following:

let result= instance.methods().deposit().call().await. Unwrap().

Why do we not need to add add_custom_asset?

You can get the base asset ID in Rust from the Provider, like this:


Regarding calling payable functions, you can do a simple call as you described if you don’t want to pass any funds, or if you’d like to include tokens in your call, you can set them in the call parameters.

add_custom_asset is used to append an unrelated token transfer to a call.

Do take a look at this post where I followed the instruction