2

my transaction is failing for some reason due to {"code":-32000,"message":"insufficient funds for gas * price + value"}

I am executing a pancakeswap transaction to swap a token for bnb. I have the gas set to 5 gwei and I have web3 getting the gas estimate that will be used.

I have more than enough bnb in my account to pay for the gas but I keep getting this error. Can anyone advise on how to solve this? I have also tried to send a transaction calling the approve function on a smart contract but I am getting the same error.

Gas:29406 Gas Price:5000000000 Value: 0

Gas*Price+value= 147030000000000

Wallet Balance 26270052976800394

TylerH
  • 20,799
  • 66
  • 75
  • 101
0xKitsune
  • 131
  • 6
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 12 '21 at 10:49
  • How do you get the gas estimate from web3 – att Dec 14 '21 at 23:16

1 Answers1

0
let gas = await web3.eth.estimateGas({
        "from": fromAddress,
    });
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Fiko
  • 47
  • 4
  • While this code may solve the question, [including an explanation](//meta.stackexchange.com/q/114762) of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please [edit] your answer to add explanations and give an indication of what limitations and assumptions apply. – Adrian Mole Jan 04 '23 at 07:15