Created
January 15, 2018 16:23
-
-
Save critesjosh/871d3db13fc97ce2ceeb32aa7b7d925c to your computer and use it in GitHub Desktop.
A relay contract for upgradable contracts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract Relay { | |
address public currentVersion; | |
address public owner; | |
modifier onlyOwner() { | |
if (msg.sender != owner) { | |
throw; | |
} | |
_ | |
} | |
function Relay(address initAddr) { | |
currentVersion = initAddr; | |
owner = msg.sender; // this owner may be another contract with multisig, not a single contract owner | |
} | |
function changeContract(address newVersion) public | |
onlyOwner() | |
{ | |
currentVersion = newVersion; | |
} | |
function() { | |
if(!currentVersion.delegatecall(msg.data)) throw; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment