0

I set the gas limit to 1 000 000 for every transaction. But each transaction takes less amount of gas than 1 000 000. Could you please explain why it happens or what I need to read to get this right. The same problem occurs when I use a call message and pass the gas limit to another contract. For example, I pass 100 000 gas but much less passed in reality.

enter image description here

enter image description here

enter image description here

1 Answer 1

0

The gas limit you set in remix is just the maximum gas you wish to spend on a given transaction. It does not mean that you will spend this much gas. The actual gas you spend depends on what your contract is doing. If there are complex calculations involved, you will spend more gas to compensate the miners for their processing power. If the total gas required for the transaction exceeds the gas limit you set, the transaction will fail.

The block gas limit is set by the network and is the maximum amount of gas allowed in a single block.

A really good breakdown of how the gas prices work is the Ethereum docs: https://ethereum.org/en/developers/docs/gas/

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.