I am trying to send a transaction quickly by adding a priority fee that is half the base fee with the following logic:

const { baseFeePerGas } = await client.getBlock();

const priorityFee = baseFeePerGas / 2n;

const hash = await wallet.writeContract({
  maxPriorityFeePerGas: priorityFee,
  maxFeePerGas: baseFeePerGas + priorityFee,

When I go to use this it throws an error which states I was trying to provide over 13 ETH worth of wei to the transaction but 9 gwei for the priority fee and 28 gwei for the max fee seems what I would expect it to be.

Insufficient funds for gas * price + value: address 0x035342Fb880F46A9F58343774F131Bf6f6757007 have 77717615752227236 want 13418145387500000000 (supplied gas 500000000)

Contract Call:
  maxPriorityFeePerGas:  8.945430258 gwei
  maxFeePerGas:          26.836290775 gwei
  data:                  0x3eb76b9c000000000000000000000000000000000000000000000000000000000000013f
  to:                    0xBE5E6De0d0Ac82b087bAaA1d53F145a52EfE1642
  from:                  0x035342Fb880F46A9F58343774F131Bf6f6757007

Shouldn't the max gas used be no more than 26836290775 wei (26.836 gwei) in this scenario? Where does the 13418145387500000000 wei come from?

1 Answer 1


I believe the issue here is with the gas limit and not the gas price.

As it mentions in the error: gas (limit) * price + value = funds used in tx

You are providing a huge gas limit (500,000,000), so currently the formula works out to be:

500,000,000 * 26.8 gwei + value = 13418145387500000000 wei

Which is more than the balance of the wallet (77717615752227236 wei)

You will want to estimate the actual gas limit before sending the transaction. In Ethers.js this is available via the provider's estimateGas() function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.