How can we use refunded GAS from a transaction in subsequent ETH transfers? In general, how is refunded GAS used? How can we check the status of the amount of refunded GAS?
1 Answer
You don't need to do anything. The gas refund is applied at the end of the transaction, so the total amount of gas your account is charged for already includes the gas refund. (E.g. if the transaction would have cost 50,000 gas but there was a 15,000 gas refund, the transaction costs only 35,000 gas.)
-
Thanks @smarx. If I want to harness the gas refund using a contract like gastoken, how is it done?– AjayAug 29, 2018 at 17:28
-
Gastoken is a clever trick, where you "store" gas by writing to storage and then get a refund by later zeroing out that storage. There's nothing special to do except set the value to zero (getting a gas refund) in the same transaction as you're doing something else. Aug 29, 2018 at 17:48
-
Ok, so do you mean I have to set the GAS limit to zero in the subsequent transaction?– AjayAug 29, 2018 at 18:55
-
No, not at all. :-) The gas refund comes from storing a 0 in storage where there used to be a non-zero value. Aug 29, 2018 at 20:52