-
-
Save wrightkhlebisol/dcce01aaf08443a183b3df1c55776038 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Base { | |
uint public num; | |
address public sender; | |
function setNum(uint _num) public { | |
num = _num; | |
sender = msg.sender; | |
} | |
} | |
contract FirstCaller { | |
uint public num; | |
function setBaseNum(address _base, uint _num) public{ | |
Base base = Base(_base); | |
base.setNum(_num); | |
} | |
function callSetNum(address _base, uint _num) public { | |
(bool status, bytes memory returnData) = _base.call(abi.encodeWithSignature("setNum(uint256)", _num)); // Base's num is set | |
} | |
function delegatecallSetNum(address _base, uint _num) public { | |
(bool status, bytes memory returnData) = _base.delegatecall(abi.encodeWithSignature("setNum(uint256)", _num)); // Base's num is set | |
} | |
} | |
contract SecondCaller { | |
function callThrough(FirstCaller _fc, Base _base, uint _num) public { | |
_fc.delegatecallSetNum(address(_base), _num); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment