I am using selfdestruct method and passing the payable address to it but receiving the following error when trying to get the value of a state variable : "Error: Returned values aren't valid, did it run Out of Gas?"

Do the value of state variables will get cleared on using self destruct or we can not access the variable after using selfdestruct method.

solidity version: v0.5.8

Tutorial followed: "Code your own crypto currency on Ethereum" by Gregory(lecture 10) on udemy

1 Answer 1


You cannot call any of the contract functions, because the contract code is no longer viable.

State variables are accessed via getter functions which the compiler implicitly adds to the contract.

Those functions, just like any other function that you implement, are not viable after destruction.

  • Does the functionality of self destruct method changed over the version upgrade because the tutorial I am following according to that the value of state variable will get cleared after destruction and in the test case they are checking the state variable to be 0(solidity version: 0.4.x).Is there any other way to write the test case for self destruct? May 5, 2020 at 9:12
  • @ShubhamPal: If you upgrade your contract using CREATE2, then the state variable getter function will be viable. Please point to the tutorial if it is relevant to your question (and please do so within the question). May 5, 2020 at 9:15
  • tutorial added to the question May 6, 2020 at 19:50

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.