1

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

0

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.

| improve this answer | |
  • 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? – Shubham Pal May 5 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). – goodvibration May 5 at 9:15
  • tutorial added to the question – Shubham Pal May 6 at 19:50

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.