1

When I was reading the library code, I came across the following comment: "the values being non-zero value makes deployment a bit more expensive, but in exchange the refund on every call to nonReentrant will be lower in amount. Since refunds are capped to a percentage of the total transaction's gas, it is best to keep them low in cases like this one, to increase the likelihood of the full refund coming into effect". I couldn't understand it, even though I reread it several times. Цhat they mean by a "refund"? Is it just a revert of transaction? Why refund will be lower?

1 Answer 1

0

There are certain cases when you get refunds for your gas usage. The exact rules have changed quite many times, but here's an article which is at least decently up-to-date.

When writing a smart contract, one can optimize the gas usage for certain scenarios. As is the case for the ReentrancyGuard library, it optimizes gas for usage, at the expense of making the deployment more expensive.

So the amount of gas refund depends on the design of the contract. Often these gas refunds are not much considered much when writing contracts, but when the scope is as small as for ReentrancyGuard, it's worth considering these gas refunds.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.