I am looking to hear about design patterns that people have implemented within Ethereum smart contracts to allow for post deploy modification of data structures.
For example, say I have a contract which contains a struct defining an Address. Should I down the line realise that I want to add an email address property to the Address.. Is there any pre-deployment design pattern consideration that would allow for me to do this.
A little more complex of an example.. If I had two properties of a contract named 'question' and 'answer', and all of a sudden I want to have multiple possible answers.. how would one go about making such a change?
My issue/concern is that if you interface with said contract through a browser for example, you could simply update the contract that the front end points to (post update).. BUT how do you resolve the problem of maintaining any contract data across update deployments..?
Thanks
T
Best Answer
You need to put in consideration the following:
This has to be planed from the start. You will need to design your smart contract taking in consideration the following 5 points:
Upgrading Broken Contracts
Example 1: Use a registry contract to store latest version of a contract
Example 2: Use a DELEGATECALL to forward data and calls
I created a story on Medium for this with title: Essential Design Consideration for Ethereum dApps (1): Upgradeable Smart Contracts