Motoro
Motoro copied to clipboard
Versioning
Feature request
As a CTO I want to be able to upload different versions of the smart contracts then I expect to have an additional smart contract Where I can redirect all requests from the old version of contract to a new one
There is a couple of ways of achieving that:
You can use delegatecall
available in solidity that will call a method in another smart contract together with changeable variable currentVersionAddress
we can call 'current' version of the contract from our 'proxy'.
example from https://github.com/shaunazzopardi/smart-contract-versioning called 'Proxy/Interface method'
address currentVersion = <someAddress>;
<type> <varName>;
function <methodName>() public returns(<type>){
if(currentVersion.delegatecall(msg.data)){
returns <varName>;
}
else{
revert();
}
}
Only Owner of the contract can modify the currentVersionAddress.
In more details it concept is explained on https://ethereum.stackexchange.com/questions/2404/upgradeable-smart-contracts
One of the limits of that approach is that you can have only variables available in the original contract, meaning you would have to either know a priori what will you require or provide a magic map
of anything.
Sources:
- https://github.com/shaunazzopardi/smart-contract-versioning
- https://ethereum.stackexchange.com/questions/2404/upgradeable-smart-contracts
- https://forum.ethereum.org/discussion/4595/versioning-of-smart-contracts
Versioning best practices https://blog.zeppelin.solutions/proxy-libraries-in-solidity-79fbe4b970fd https://medium.com/rocket-pool/upgradable-solidity-contract-design-54789205276d
Consider moving to Zeppelin OS https://docs.zeppelinos.org/docs/start.html