2

I am running in a private ethereum network which I init with a genesis.json file that contains "gasLimit": "31415926" Now I am wondering how I can read that via web3, any suggestions? (I want to make sure the limit is set correctly).

8

Asking for the last block mined, it will return the gasLimit of the block https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethgetblock

var block = web3.eth.getBlock("latest");
console.log("gasLimit: " + block.gasLimit);
  • 1
    The gas limit I am getting from this is absurdly high (For an individual transaction), but this is the gas limit for the whole block though, correct? If so, then to estimate the gas I should use on an individual transaction, do I just divide by the number of transactions in said block? Or is it safe to just always use the gasLimit minimum of 21000? – Albert Renshaw Dec 12 '18 at 1:28

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.