Open patrykmat opened 6 years ago
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:
Consider moving to Zeppelin OS https://docs.zeppelinos.org/docs/start.html
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