Error "InsufficientFeeAmount" when I'm trying to transfer some asset using rust sdk

Trying to transfer my token from wallet to recipient using this tutorial

#[tokio::test]
async fn _transfer() {
    let (wallet, dapp, provider) = setup().await;
    let decimals = dapp.methods().decimals().simulate().await.unwrap().value;
    let symbol = dapp.methods().symbol().simulate().await.unwrap().value;
    let asset_id = AssetId::from_str(USDT_ADDRESS).unwrap();

    println!("Decimals: {decimals}\nSymbol: {symbol}");

    let balance = wallet.get_asset_balance(&asset_id).await.unwrap();
    println!(
        "Wallet balance: {} {symbol}",
        format_units(balance, decimals)
    );

    let recipient = Bech32Address::from_str(RECIPIEND_ADDRES).unwrap();
    let recipient = Wallet::from_address(recipient, Some(provider.clone()));

    let amount = parse_units(10, decimals);
    let mut inputs = vec![];
    let mut outputs = vec![];

    let input = wallet
        .get_asset_inputs_for_amount(asset_id, amount, 0)
        .await
        .unwrap();
    inputs.extend(input);

    let output = wallet.get_asset_outputs_for_amount(recipient.address(), asset_id, amount);
    outputs.extend(output);

    let mut tx = Wallet::build_transfer_tx(
        &inputs,
        &outputs,
        TxParameters::new(Some(1), Some(1000000), None),
    );
    wallet.sign_transaction(&mut tx).await.unwrap();

    let _receipts = provider.send_transaction(&tx).await.unwrap();

    let recipient_balance = recipient.get_asset_balance(&asset_id).await.unwrap();
    let balance = wallet.get_asset_balance(&asset_id).await.unwrap();
    println!(
        "Wallet balance: {} {symbol}\nRecipient balance: {} {symbol}",
        format_units(balance, decimals),
        format_units(recipient_balance, decimals),
    )
}

But I have this error:

thread 'actions::transfer::transfer' panicked at 'called `Result::unwrap()` on an `Err` value: ProviderError("Response errors; InsufficientFeeAmount { expected: 1, provided: 0 }")', tests/actions/transfer.rs:49:58
stack backtrace:...

Please help me the fee amount correct

3 Likes

I used wallet.transfer and it worked

Just replaced that

    let amount = parse_units(10, decimals);
    let mut inputs = vec![];
    let mut outputs = vec![];

    let input = wallet
        .get_asset_inputs_for_amount(asset_id, amount, 0)
        .await
        .unwrap();
    inputs.extend(input);

    let output = wallet.get_asset_outputs_for_amount(recipient.address(), asset_id, amount);
    outputs.extend(output);

    let mut tx = Wallet::build_transfer_tx(
        &inputs,
        &outputs,
        TxParameters::new(Some(1), Some(1000000), None),
    );
    wallet.sign_transaction(&mut tx).await.unwrap();

    let _receipts = provider.send_transaction(&tx).await.unwrap();

to this

    let _receipts = wallet
        .transfer(
            recipient.address(),
            amount,
            asset_id,
            TxParameters::new(Some(1), Some(1000000), None),
        )
        .await
        .unwrap();

The working version of the code:

Admin, please fix this article
https://fuellabs.github.io/fuels-rs/v0.32.2/cookbook/transfer-all-assets.html?highlight=transfer#transfer-all-assets

1 Like

You can see the full test here: fuels-rs/lib.rs at master · FuelLabs/fuels-rs · GitHub . You might have a version mismatch that is causing the error.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.