Issue with getTransactionCost Returning Incorrect Gas Limit for Contract Function Calls

Hello Fuel Community,

I’ve encountered an issue with the getTransactionCost function when working with a complex system of five contracts. The problem arises when I attempt to use getTransactionCost to estimate the gas limit for a deposit_collateral function call in one of my contracts. The estimated gas limit provided by getTransactionCost seems to be incorrect, leading to transaction failure.

  • Issue: The getTransactionCost function is returning a gas limit that is lower than what is actually required for the transaction to succeed.
  • Error Encountered: The transaction fails with the error message: “Gas limit ‘33650’ is lower than the required: ‘94690’.”

Code

const { gasUsed } = await account.contracts?.vaultContract.functions.deposit_collateral()
    .callParams({
        forward: { amount: amount.toString(), assetId: TOKENS_BY_SYMBOL.USDC.assetId },
    })
    .txParams({ gasPrice: 1 })
    .getTransactionCost();

await account.contracts?.vaultContract.functions.deposit_collateral()
    .callParams({
        forward: { amount: amount.toString(), assetId: TOKENS_BY_SYMBOL.USDC.assetId },
    })
    .txParams({ gasPrice: 1, gasLimit: gasUsed })
    .call();

Hello @sway the TypeScript SDK team is currently investigating this potential bug associated with the getTransactionCost() method. We’ll make sure to keep you updated on our progress. Thank you! :blush:

1 Like

I created a new issue here.

1 Like