I'm developing Dapp, In that app one function consuming a gas but I am providing sufficient ether at the time of initiating transaction by web3 for the Dapp Users,Then also it is showing out of gas problem but it is consuming around 0.00006732 eth, but i am providing 0.0035 eth and i kept a gas limit as 6000000 gas.

Transferring gas to user transaction:

 const txn = {
   from: process.env.OWNER_ADDRESS,
   to: userAddress,
   value: 3500000000000000,
   gasLimit: web3.utils.toHex(6000000)

1st I am initiating this transaction from owner to user

Token transfer transaction by user:

                       const txn = {
                           from: senderAddress,
                           to: process.env.WALLET_CONTRACT_ADDRESS,
                           data: contract.methods.transferToken(process.env.TOKEN_CONTRACT_ADDRESS, receiverAddress, numOfTokens).encodeABI(),
                           gasLimit: web3.utils.toHex(6000000)

after that 1st transaction complete I initiating this transaction.

  • 1
    The unit for the gas limit is "gas". There's no way to set the gas limit in "gwei". And a gas price of 3500000 gwei is absurdly high... a good gas price now is 1 or 2 gwei. – smarx Mar 11 at 5:30
  • Thank you for your quick response, yes you are correct. It's my mistake, 350000 gwei is the value I am transferring to user. I am also using gas price is 1 gwei only, I have updated the question as well. Kindly check and let me know. – Nithin Mar 12 at 5:44
  • Again, gwei is not a unit for gas. It's completely unclear what you're doing. Perhaps you can share code or a link to the transaction on Etherscan or something else. – smarx Mar 12 at 6:26
  • Thank you for your quick response, I have updated the question as well. Kindly check and let me know. – Nithin Mar 12 at 6:55
  • You set the gasLimit too high 6M. When you submit the transaction you need to have enough ether to cover the full gasLimit. At 35 gwei you will need 0.21 ether to cover for 6M of gas. Even if your transaction only uses 200K of gas you need to pay for 6M of gas in advance (at the end the unused gas will be returned). – Ismael Mar 13 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.