Created
June 20, 2021 17:06
-
-
Save hadv/fd241f13edb528157312e56803ea67de to your computer and use it in GitHub Desktop.
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
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