-
-
Save PJUllrich/0a71071071d4406ebea83bbbcbc7536a to your computer and use it in GitHub Desktop.
Solidity Call, Callcode, Delegatecall Demo. Deploy contracts. Call functions and see how sender changes in either B, or C.
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.4.24; | |
contract A { | |
address public sender; | |
function dcall(B other, C child) public { | |
other.dcall(child); | |
} | |
} | |
contract B { | |
address public sender; | |
function cal(address other) public { | |
other.call(bytes4(keccak256("set()"))); | |
} | |
function ccode(address other) public { | |
other.callcode(bytes4(keccak256("set()"))); | |
} | |
function dcall(address other) public { | |
other.delegatecall(bytes4(keccak256("set()"))); | |
} | |
} | |
contract C { | |
address public sender; | |
function set() public { | |
sender = msg.sender; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment