I am developing a smart contract in truffle. I'm having some trouble understanding how GAS works in Ethereum. I used the following parameters in my Rinkeby test net:

gas limit: 4600000 
gas price: 10000000000 (10Gwei)

This means that the Gas limit is set at: 4600000 * 10000000000 ~ 0.046 ETH ~ 17 $

On the other side, I have 0.0303 ETH (~11$) on the mainnet and according to this site https://ethgasstation.info/ I put 100Gwei as gas price and then I set 30000 as gas limit (because 100Gwei * 30000 is about 10$).

I've got this error during deploy in dry run:

enter image description here

My question is: what values I need to use to deploy and use a contract? Who decides these values? Gas price seems to change very fast. Do I need to constantly update these values? Do I need to have more money in my wallet to deploy a contract ? How can I estimate all costs?

  • This means that the Gas limit is set at: 4600000 * 10000000000 - no, this means that Gas limit is set to 4600000 and Gas price is set to 10000000000. Oct 28, 2020 at 17:22
  • The transaction that you're executing cannot exceed 4600000 gas. Oct 28, 2020 at 17:23
  • And the account that you are executing this transaction with cannot hold less than 4600000 * 10000000000 + the amount of wei that you are passing in the transaction. Oct 28, 2020 at 17:24
  • In fact, that's exactly what the error message tells you - the upfront cost (100Gwei * 30000 + 0 wei which you are passing) is more than what your account holds. Oct 28, 2020 at 17:26
  • Yes thank you it was a mistake. But still I'm having trouble to determinate the values
    Oct 29, 2020 at 11:20

1 Answer 1


Well, the estimate is totally dependent on the Gas Limit. And the error which you are facing is not due to gas limit/gas price. It is coming because you don't have enough funds in your wallet to deploy the contract.

And if you are seting the limit then make sure your entring the right amount. Because if not then your transaction may get Out Of Gas. There is no worries with Gas Price you can set it accoring to your convience.

Now we come to your error:

  1. There should be 30000000000000000 = 0.03 ETH in your wallet at the time of deployment
  2. You only had 12626940000000000 = 0.01262694 in your wallet at the time of deployment.

So, that's the reason your transaction/deployment in not done.

  • Thank you but still I do not understand. 0.01262694 in your wallet at the time of deployment. why does it decrease to that value during deploy?There are still 0.03ETH on the wallet. Maybe because there are more transaction and second one does not have enough money? Suppose I need to put ~ 5$ (or 4€) as limit for all deploy. Could you help me to set the values?
    Oct 29, 2020 at 10:04
  • 4 = 0,012 ETH = 12000000000000000 Wei Suppose 10Gwei (I know it is low) 12000000000000000 / 10000000000 = 1200000 <- Gas Limit Then it says: "Migrations" -- transaction underpriced. But if I put 30Gwei as gasprice than I do not have enough gas.
    Oct 29, 2020 at 10:06
  • I did another deploy with the same 120000 as gas limit and 10Gwei and it worked. Now it is mining for about 1 hour. I think I do not understand how this works.. i do not know how to compute the gas limit correctly..
    Oct 29, 2020 at 11:20
  • First of all your transaction is undermine about 1 hour due to the low gas price, not the limit. And you can easily get the gas limit on some GUI tools like remix. Currently, the Gas Price on mainnet is about 73 Gwei. Oct 29, 2020 at 11:31

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.