4

I'm running geth with the following option:

--gasprice 21000

But if I execute the following command:

> eth.gasPrice

It gives me 20000000000.

3
  • 1
    Why are you setting the gasprice to 21000? – Tjaden Hess May 17 '16 at 22:01
  • 1
    It's just a random number. I'm running into a "VM create err: Contract creation code storage out of gas" when trying to deploy a contract, the first thing I've tried was to lower the gas price. – Henrique Barcelos May 17 '16 at 22:04
  • 1
    Ah, okay. 21000 happens to be the gas for a common transaction, so it seemed a bit odd – Tjaden Hess May 17 '16 at 22:06
3

The --gasprice flag sets the minimum price per gas that your miner will accept when mining transactions.

The eth.gasPrice command gives the current gas price, which is based off the moving averages of the gas prices sent in the last few blocks. This is not the same as the --gasprice flag.

Also, you may be confusing gas and gas price. Every simple transaction takes 21000 gas, regardless of the gas price. Setting the gas price may not be doing what you think it is.

5
  • 1
    I understand that. 21000 was a random number I've tried to put there. The problem is I'm running a clean install, on my own network, so the gasPrice should be set because there is no transactions mined at all, am I wrong? – Henrique Barcelos May 17 '16 at 22:03
  • 1
    No, eth.gasPrice defaults to 20 GWei, since that is what it is on the main net. It should adjust as transactions are mined – Tjaden Hess May 17 '16 at 22:05
  • 1
    But I'm not running on the main net, I'm running on a private network, with my own network id and my own genesis block. – Henrique Barcelos May 17 '16 at 22:06
  • 1
    Yes, but the 20 GWei number is hard coded into the client – Tjaden Hess May 17 '16 at 22:07
  • 1
    You don't need to use eth.gasPrice though, you can set gas manually with each transaction – Tjaden Hess May 17 '16 at 22:08

Your Answer

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

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