1

I'm trying to estimate Gas for a contract method (both using parity and geth - tried web3py and web3js). Contract is deployed and proven to be working.

When I use:

  • estimateGas and geth (providing: to, from, data I get gas > 6 700 000, which seems to be an error as it's the whole available gas for the current block
  • estimateGas and parity (providing: to, from, data I get the following error: Internal("Requires higher than upper limit of 1000000000000")
  • JSONRPC and trace_callreturns around 49000 (parity)
  • JSONRPC and method eth_estimateGas returns 77858 (both for parity and geth)
  • however when I actually create a transaction it consumes much more Gas Used By Txn: 108140 - which doesn't match the number returned by eth_estimateGas - if I click trace on Etherscan (parity/geth) - gas from the traces matches 77858, however 108140 is used to process the transaction.

Am I missing something here? How can I calculate the gas properly? There is nothing unusual in the contract - constant number of steps. I believe that I should be able to even calculate this manually with a pen and paper.

I've tried a few transactions and gas used by txn is always higher from 30000 to 32000 units than estimated gas.

  • Are you putting in the data parameter? – Marc Alexander Nov 15 '17 at 22:50
  • Yes, as mentioned above I provide to, from and data. Have you came across similar issues? – JackinHouse Nov 15 '17 at 23:53
  • This seems quite weird. How are you calculating the data parameter? – Prashant Prabhakar Singh Nov 18 '17 at 20:14
  • I wrote a function to calculate data parameter. In order to validate my function, I've created 5 real transactions and obtained data by web3.eth.getTransaction() and it was matching data generated by my function. I've tried even creating a transaction, getting data by web3.eth.getTransaction() and estimating gas in the same second, but returned value was different than the one on etherscan. – JackinHouse Nov 18 '17 at 21:17

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.