Closed chenyunecjtu closed 6 years ago
Could you format your post please? It's hard to read and... hey, you know, we are developers, we are lazy :dagger:
Seriously, from what I read, you put 21k for a transfer function that is in a contract. It will cost more that that. Put something like 200k, should be fine.
@Andromelus I have the same problem. Please see below logs:
{ jsonrpc: '2.0',
id: 84,
method: 'eth_estimateGas',
params:
[ { from: '0x00ba938cc0df182c25108d7bf2ee3d37bce07513',
to: '0x499d511d6bc3a1a267439645cf50d5dddc688d54',
data: '0x4f15078700000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000048000000000000000000000000000000000000000000000000000000000000004e0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000a6d07f3530430f87e19c25d999b627f4fe32e200000000000000000000000000ba938cc0df182c25108d7bf2ee3d37bce075130000000000000000000000004db7ba0b930f0d886987fb2abc7cd79725afafcd000000000000000000000000e76009fd1e1f7ef6d91ecfcd9c6233fd986f1cd300000000000000000000000088a64b5e882e5ad851bea5e7a3c8ba7c523fecbe000000000000000000000000006dc83e5b21854d4afc44c9b92a91e0349dda1300000000000000000000000000ba938cc0df182c25108d7bf2ee3d37bce07513000000000000000000000000e76009fd1e1f7ef6d91ecfcd9c6233fd986f1cd30000000000000000000000004db7ba0b930f0d886987fb2abc7cd79725afafcd00000000000000000000000088a64b5e882e5ad851bea5e7a3c8ba7c523fecbe0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000001f01eed3000000000000000000000000000000000000000000000000000000000b34483300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005a68916c9a8ad221298b0cbb4324597a3ffa54fc151703ac7fcf01fcecf27e5c712df022000000000000000000000000000000000000000000000000000000002e857b010000000000000000000000000000000000000000000000000000000018639e4e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005a68916c507d8caf2b60f7a74a36b09394a1b5d6f63957e8251817385a955ab6ac5a1f7f0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000b3448330000000000000000000000000000000000000000000000000000000018639e4e0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001b000000000000000000000000000000000000000000000000000000000000001b000000000000000000000000000000000000000000000000000000000000000211089a51951d534b9bf6527ac2f18d50a330b079a9980ded93c82a8b2f6eaa6be7bf1c2c10471790792518c3b47cbe0abbae0d7e987cd1410e24c51a4e79d06b00000000000000000000000000000000000000000000000000000000000000022af6cfba8d8874e9d5edba13a9f96c91581c6c03b2c3525b27c2bc2da5f7cb553e557de403e52a27ffa140c4fb66f89c8f214d1226447be27cbd07dc0ed6949b' } ] }
{ jsonrpc: '2.0',
error:
{ code: -32015,
message: 'Transaction execution error.',
data: 'Internal("Requires higher than upper limit of 79999990")' },
id: 84 }
The gas estimation is random. Sometimes pass sometimes throws error. Using web3: 0.20.4
Same here. It was working similar code above. But for reason gives the same result. I already tested downgrading to 0.20.3. Maybe another dependency?
I think I already got it. With geth version 1.7.2 this do not happen. Only 1.7.3. I guess if anyone uses INFURA, also uses the 1.7.3. https://github.com/MetaMask/metamask-extension/issues/2720 https://github.com/ethereum/go-ethereum/pull/15477
This still happens with ganache-cli. Paradoxically, I found that the answer was to include gas in the actual call to estimate gas.
This fails:
let gas = await contract.myfunc.estimateGas(arg1, arg2, {from: accounts.sysAdmin});
While this succeeds:
let gas = await contract.myfunc.estimateGas(arg1, arg2, {
from: accounts.sysAdmin,
gas: 9950000
});
Hope this helps some poor soul out there...
contracts.methods.transfer(body.to, 10).estimateGas({from: body.from, gas: 21000}, function (error, gas) { console.log(error+ gas); }).then(gas=>{ console.log("gas="+gas); // gas = 3000000; contracts.methods.transfer(body.to, 10).send({from: body.from, gas: gas, gasPrice:price, nonce:number}) .on('transactionHash', (transactionHash) => { res.send(responseJson(0, '', {txhash:transactionHash})) }) .on('confirmation', function(confirmationNumber, receipt){ notify('/api/notify/test', {confirmation_number: confirmationNumber, txhash: receipt.transactionHash}) }).on('error', function (error) { res.send(responseJson(-1, "send_transaction failed "+error)); }); }).catch(error => { res.send(responseJson(-1, "send_transaction failed "+error)); });
Error: Returned error: gas required exceeds allowance or always failing transactionundefined