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!