Recommended Gas Limit for Single Transaction
Recommended Gas Limit for Single Transaction
Loading saved threads...
Jerry Ji · External communityPost link
External question — Ethereum Stack Exchange
Author: Jerry Ji
Original post: https://ethereum.stackexchange.com/questions/53357
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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.
Quote
Report
Edmund Edgar · External communityPost link
External answer — Ethereum Stack Exchange
Author: Edmund Edgar
Original post: https://ethereum.stackexchange.com/a/53359
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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.
Quote
Report
Jerry Ji · External communityPost link
External answer — Ethereum Stack Exchange
Author: Jerry Ji
Original post: https://ethereum.stackexchange.com/a/54461
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
It turns out MetaMask has its own gas limit of 6M --
So for an end-user facing contract, 6M is the upper bound for now.
Quote
Report
Post Reply
Checking account access…