Skip to content

Instantly share code, notes, and snippets.

@critesjosh
Created January 15, 2018 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save critesjosh/871d3db13fc97ce2ceeb32aa7b7d925c to your computer and use it in GitHub Desktop.
Save critesjosh/871d3db13fc97ce2ceeb32aa7b7d925c to your computer and use it in GitHub Desktop.
A relay contract for upgradable contracts
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