3

I am trying to deploy a contract with web3, and always get an error Error: exceeds block gas limit, even for correct or empty contract code.

Actually, gasEstimates always throws : Error: gas required exceeds allowance or always failing transaction

Even for an empty contract, the gas estimate is infinite :

var compiledContract = solc.compile("pragma solidity 0.4.17; contract Contract { }"); var abi = compiledContract.contracts[':Contract'].interface; var abiArray = JSON.parse(abi); var bytecode = compiledContract.contracts[':Contract'].bytecode; var gasEstimate=web3.eth.estimateGas({from : web3.eth.coinbase, data : web3.toHex(bytecode)}); throws "exceeds allowance".

Please do you know where I can be wrong ?

Thank you, Pierre.

0

In fact I did two errors, here there are in case it can help someone:

  1. To the data field passed to estimateGas must be data : '0x'+bytecode and not data : web3.toHex(bytecode).

  2. When deploying the contract I had put too much gas, check the current block gasLimit field.

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.