0

Current mainnet gas limit per block is 8M (7.99), that of Ropsten is 9M (which is actually rather surprising as it was 4.7M two months ago and I did complain about it...).

Given the above, what's the recommended best-practice gas limit for a single transaction? Would 6M be too high and risk not being picked by the miners if I'm aiming for median gas price? How about 4.7M?

After all, is there any statistics on the distribution of the gas used by mainnet transactions?

Edit: It seems I've not made myself clear enough. I'm referring to the transaction from my contract function. The function does something iteratively, and it's up to me to decide how many iterations to process within one transaction. My question is basically trying to gauge the maximum amount of gas "safe" to use with a reasonable gas price.

0

The gas limit should be as high as your transaction will consume, and no higher. The amount of gas a transaction consumes depends on what it does. (Bear in mind that if your transaction results in gas refunds, for example because it deletes storage data, you still need to account for it in the gas you supply.)

Most miners will fill blocks up to the limit, and it's OK to set a limit that takes close to or all the gas available in a block, but since miners take transactions with higher fees first, this will increase the gas level you will need to set to outbid other transactions that could fit in the block. So you will need to compensate for the higher gas limit by setting a higher gas price. See https://ethgasstation.info/ for specific data on how high a gas price you are likely to need for any given gas limit.

If you're just doing a simple send, just use 21,000.

0

It turns out MetaMask has its own gas limit of 6M --

MetaMask Gas Limit

So for an end-user facing contract, 6M is the upper bound for now.

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.