Skip to content

Instantly share code, notes, and snippets.

@karlfloersch
Last active August 21, 2021 06:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karlfloersch/b71c9e2453cf40ea886b32c538f4064e to your computer and use it in GitHub Desktop.
Save karlfloersch/b71c9e2453cf40ea886b32c538f4064e to your computer and use it in GitHub Desktop.
pragma solidity ^0.7.0;
contract EOAProxy {
address implementation = DEFAULT_IMPL_ADDR;
function _eoaUpgrade(address _newImplementation) external {
require(msg.sender == address(this));
implementation = _newImplementation;
}
fallback() external {
address impl = implementation;
assembly {
pop(delegatecall(gas(), impl, 0, 0, 0, calldatasize()))
}
}
}
@karlfloersch
Copy link
Author

karlfloersch commented Oct 22, 2020

Example upgrade

import EOAProxy
contract Impl {
  function upgradeImpl(address newAddr) {
    EOAProxy(address(this))._eoaUpgrade(newAddr);
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment