Last active
March 4, 2022 14:46
-
-
Save sibelius/cc7a8e7a52752b533a1f2aec752bca05 to your computer and use it in GitHub Desktop.
Delegate function call to another smart contract implementation
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.5.0; | |
contract DelegateProxy { | |
address internal implementation; | |
function() external payable { | |
address addr = implementation; | |
assembly { | |
calldatacopy(0, 0, calldatasize()) | |
let result := delegatecall(gas(), addr, 0, calldatasize(), 0, 0) | |
returndatacopy(0, 0, returndatasize()) | |
switch result | |
case 0 { revert(0, returndatasize()) } | |
default { return(0, returndatasize()) } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment