After finding out how to estimate contract tx fees thx to How to estimate the cost to call a Smart Contract method? and Syntax for calling contract state changing methods I tried to use all that knowledge and implement my own contract transaction with previous gas estimation, but they differ quite a lot. Gas estimated is 27,348 meanwhile Gas consumed is 181,080. So, what is wrong? Is this gas estimation process well done when dealing with smart contracts?

This is the data I used to estimate the gas for the endpoint: "start(address, address)" in a Smart Contract with address 0x27c042342C9ba937214117e11A4970A6145034cB

web3_sha3(endpoint) = 0xaa6d19c0b1d22f6983033c255695177ad1db0a0aad0435b6f6a367b48d4b37f4 
arguments = "0xa7e3c7c227c72a60e5a2f9912448fb1c21078769, 0xf28dafbfeb41bf32869c9d498da0d651d0206ed4" 
strhex(arguments) = 0x3078613765336337633232376337326136306535613266393931323434386662316332313037383736392c20307866323864616662666562343162663332383639633964343938646130643635316430323036656434 
data = 0xaa6d19c03078613765336337633232376337326136306535613266393931323434386662316332313037383736392c20307866323864616662666562343162663332383639633964343938646130643635316430323036656434

yielding a Gas estimation of: 27,348

On the other hand, following tx is performed:

sc.start.sendTransaction("0xa7e3c7c227c72a60e5a2f9912448fb1c21078769", "0x47978a69f410d0f61850c92acdb0d4c464d70937", {from:"0x3b877e80b5c0b29d88f3768ed4292b35fdd93a9d", value:"0x55ae82600", gas:1000000});

txHash: 0xbad5639d7f02cfb1658580eb8cab5f950d379ee8197f423178391dc70701459f

and once the tx has been mined this is the resulting gas values:

Gas: 1,000,000
Gas Used By Transaction: 181,080

So, why estimated gas is so off? Thx in advance!

  • 1
    Different code paths taken during the estimate and the one that gets mined? It also seems the 2nd argument in the sendTransaction is different from the one provided in the estimate. ethereum.stackexchange.com/questions/266/…
    – eth
    Oct 14, 2016 at 16:05

2 Answers 2


I have found something, maybe it could help others...

Signature to hash is NOT "start(address, address)" but instead "start(address,address)". This white space changes everything.

I've also found very valuable info about passing parameters to contracts on https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#examples


Now, it works like a charm!

endpoint = "start(address,address)" 
web3_sha3(endpoint) = 0x3ccfe887556b4c598501287bcd4528f0b8830f303e150d3b4c3ac9831b7989a8 
arguments = Array (
    [sellerAddress] => Array
            [type] => address
            [value] => 0xa7e3c7c227c72a60e5a2f9912448fb1c21078769

    [thirdPartyAddress] => Array
            [type] => address
            [value] => 0xf28dafbfeb41bf32869c9d498da0d651d0206ed4
data = 0x3ccfe887000000000000000000000000a7e3c7c227c72a60e5a2f9912448fb1c21078769000000000000000000000000f28dafbfeb41bf32869c9d498da0d651d0206ed4

gasEstimated = 181,080

Arguments must be encoded one after the other, each one 32-bytes 0-left-padded, so each one uses 64 hex characters to be represented.

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.