Search code examples
blockchainethereum

Where ethereum contact instance state is stored?


Does ethereum contact instance state stored in blockchain? And when an updated contract is deployed ,how to restore previous instance state into the new contact instance?


Solution

  • Look at this answer for information on how the state is stored.

    Migrating the state to a new version of your contract is the developer’s responsibility. If the data for your contract is tightly coupled (resides in the same contract), then you have to extract the data manually and deploy it with the new version.

    The more accepted way is to create a separate contract for the data and pass the address into your contract that is responsible for executing the business logic.