Skip to content

Instantly share code, notes, and snippets.

@hadv
Created June 20, 2021 17:06
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 hadv/fd241f13edb528157312e56803ea67de to your computer and use it in GitHub Desktop.
Save hadv/fd241f13edb528157312e56803ea67de to your computer and use it in GitHub Desktop.
pragma solidity ^0.8.3;
contract Proxy {
address immutable public implementation;
event Received(uint indexed value, address indexed sender, bytes data);
constructor(address _implementation) {
implementation = _implementation;
}
fallback() external payable {
address target = implementation;
// solhint-disable-next-line no-inline-assembly
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), target, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {revert(0, returndatasize())}
default {return (0, returndatasize())}
}
}
receive() external payable {
emit Received(msg.value, msg.sender, "");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment