InsufficientFeeAmount Error when dealing with predicate

I am trying to send a tx request that will send the asset in the predicate back to a owner of the asset. I try it with this predicate code. Here is how I try to do it with fuel ts-sdk v0.75.0:

    const req = new ScriptTransactionRequest({
      gasPrice: 1,
      gasLimit: 10000
    });
    req.addCoinInput(walletCoin)
    req.addPredicateResource(predicateCoin, predicate)
    req.addChangeOutput(wallet.address, BaseAssetId)
    req.addCoinOutput(wallet.address, 1000, BaseAssetId)

    const tx2 = await wallet.sendTransaction(req)
    await tx2.waitForResult();

But before approving the tx on the extension, I get this error:

> Error: {"Validity(InsufficientFeeAmount":[{"errorMessage":"Validity(InsufficientFeeAmount { expected: 2383, provided: 2000 })"}]}

@fsociety Thanks for notifying us about this.

I will investigate the issue.

3 Likes

Hi @Torres-ssf! Any update on this?

@fsociety sorry for the late response.

I will investigate it this week.

In the mean time, can you use this approach instead when preparing the TX request:

    const predicateAmount = 1000;

    const req = new ScriptTransactionRequest({
      gasPrice: 1,
    });

    const predicateCoin = await predicate.getResourcesToSpend([[predicateAmount, BaseAssetId]]);

    req.addPredicateResources(predicateCoin, predicate);
    req.addCoinOutput(wallet.address, predicateAmount, BaseAssetId);

    const { gasUsed, requiredQuantities, maxFee } = await wallet.provider.getTransactionCost(req);

    req.gasLimit = gasUsed;

    await wallet.fund(req, requiredQuantities, maxFee);

    const tx2 = await wallet.sendTransaction(req);
    await tx2.waitForResult();

When I submitted the Tx like this, It seemed I was running into another error that appears to be specific to your predicate code.

I am still validating this, but I am not sure if this revert code can be used within a Predicate.

Have you succeeded in using this predicate on Rust SDK?

I did not try with Rust sdk

@fsociety Are you still facing this problem?

After some investigation, I’ve noticed that this problem is happening because the transaction is not being funded with enough resources to pay for the TX fee.

This can be solved by using the code snippet that I’ve provided here

Please let me know if you still need some help with this.

1 Like