Skip to content

Instantly share code, notes, and snippets.

@yhuag
Created August 8, 2018 15:03
Show Gist options
  • Save yhuag/188fabfbb698dc35be7cbe0e2313161c to your computer and use it in GitHub Desktop.
Save yhuag/188fabfbb698dc35be7cbe0e2313161c to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.24;
contract Math {
uint public ans;
function add(uint a,uint b) public {
ans = a + b;
}
}
contract Delegate {
uint public ans;
address public target;
function setTarget(address _tar) public {
target = _tar;
}
function callAdd(uint c,uint d) public {
target.delegatecall(bytes4(keccak256("add(uint256,uint256)")), c,d);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment