5

A transaction may have some gas refunds, but such refunds can only be used within the transaction: the gas refund is not converted to ether and refunded to the sender's account.

How can contracts be designed to use gas refunds, what are usecases, and what are actual coded contracts that are using gas refunds?

3

Your question is slightly ambiguous but I'll attempt to answer using my own interpretation of the question "how can contracts be designed to use gas refunds". The answer is they can't; they can't because refunds are always returned to the ORIGIN (i.e. the initial executor). Contract don't have access to this refund pool and renders it therefore useless (apart from the ability to make execution cheaper).

the gas refund is not converted to ether and refunded to the sender's account.

Refunds are actually converted to ether (go-ethereum/core/state_transition.go):

sender, _ := self.from() // err already checked
remaining := new(big.Int).Mul(self.gas, self.gasPrice)
sender.AddBalance(remaining)

What happens during the state transition:

  1. Reserve tx.gas and make sure tx.sender has enough funds;
  2. Reduce tx_fee of 21.000;
  3. Reduce execution gas (amount of gas required for the execution);
  4. Add refund to tx.sender (R * tx.gasPrice where R is gas refund)

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.