0

After a contract has been self destructed, I understand that I will not be able to call the contract anymore to get its most recent state values before it was destructed.

However, is it possible to still get the the historical state values in and events emitted by the contract that has been destructed?

I read that all of the world states of that selfdestructed contract will be deleted. I'm not exactly sure what's the scope of the deletion.

Just to provide some context, my intention is to index my contracts, which some of them may eventually get destructed, using the Graph. However, my concern is whether this would still be feasible given that some of the contracts might already have been destructed at the time when the indexer queries against the blockchain.

2
  • Every single state is stored in blocks (that's literaly the purpose of the blockchain). Consequently, you just have to browse through the old blocks to get the old states. Mar 11, 2022 at 9:14
  • @Itération122442 Does this mean that previous states values of a selfdestructed contract is still available on the blockchain? What about the events emitted by that selfdestructed contract?
    – xenon
    Mar 11, 2022 at 9:15

1 Answer 1

1

Blockchain history is never altered (except chain reorganizations, which are not relevant here). Whatever was in blockchain at time X, stays there forever.

Using selfdestruct on a contract simply deletes it from future blocks. In theory, another contract might be deployed to the same address later, but this is very unlikely (due to how improbable address collisions are). So you can query the blockchain at block X for data that occurred at block X, and you'll always get the same data back.

Note that you'll need an archive node to be able to query historical blocks further in the past.

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.