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();