How can I update the smartcontracts of my Truffle dapp which are deployed in the Ethereum blockchain?
Great answer found here.
From axic in Ethereum Stack Exchange site:
Contract code is immutable, the storage is mutable, but you cannot execute code placed into storage, at least for now.
Bugfixes to contracts
As for bugfixes, the common pattern is to have proxy or lookup contracts to be a gateway to the real one, which in case of a change or bugfix would be replaced. Replacing it also means losing the old storage contents.
Keeping storage
If you want the ability to upgrade code, while keeping storage, you could think of separating storage and logic. Have a dedicated storage contract, which accepts write calls from trusted addresses (e.g. the logic contracts). All important storage should be associated with this one.
Accessing storage after selfdestruct
As of today there is no real pruning implemented even in the case of selfdestruct, but that should definitely come in the future. There are several EIPs discussing this.
Even if pruning is implemented, it shouldn't happen in an instant and you should be able to read storage from the last state. It is also planned to have archive nodes to keep states indefinitely -- not sure that is feasible without limitations just by judging at the growth of the blockchain.
Redeploying at same address
In short: practically this is not possible. The contract addresses are calculated from the sender and the nonce. The nonce is sequential, there cannot be any gaps and there cannot be duplicates.
In theory it is possible to arrive at the same hash with a different nonce and address combination, but the likelyhood is small.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With