0

Destroying two contracts: (1) contract A with 1 integer variable stored in it and (2) contract B with 100 integer variables stored in it, would result in the same amount of refund: 24000 gas. So does the self-destruct clear all the contract variables and just not give the refunds for deleting them? Or it just removes the contract reference but doesn’t remove its variables from the current EVM state?

2
0

It does clear the storage, but there is a limit for the refund you get.

Deleting a variable refunds 15,000 gas up to a maximum of half the gas cost of the transaction

https://medium.com/coinmonks/gas-optimization-in-solidity-part-i-variables-9d5775e43dde#:~:text=Ethereum%20gives%20us%20a%20gas,gas%20cost%20of%20the%20transaction.

3
  • So presumably 24000 is the most refund you can get? – MahMoo Sep 23 '20 at 15:25
  • I assume yes, if your transaction only do "self destruct"... you can try to change something in another contract and destory the first contract within the same transaction.. so is the gas cost of the transaction is much more and probably you will refund more @MahMoo – Majd TL Sep 23 '20 at 18:43
  • and self destrcut is useless in most of the cases... anyone can see the data in the last block before the destruct.. – Majd TL Sep 23 '20 at 18:46

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.