Skip to content

Instantly share code, notes, and snippets.

@ConsenSys-Academy
Last active October 19, 2022 09:42
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save ConsenSys-Academy/de1b2000f3682f0cfba784d0cb5400e7 to your computer and use it in GitHub Desktop.
Save ConsenSys-Academy/de1b2000f3682f0cfba784d0cb5400e7 to your computer and use it in GitHub Desktop.
pragma solidity >=0.7.0 <0.9.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));
}
function delegatecallSetNum(address _base, uint _num) public {
(bool status, bytes memory returnData) = _base.delegatecall(abi.encodeWithSignature("setNum(uint256)", _num));
}
}
contract SecondCaller {
function callThrough(FirstCaller _fc, Base _base, uint _num) public {
_fc.delegatecallSetNum(address(_base), _num);
}
}
@ParsaAminpour
Copy link

Greate

@davidpius95
Copy link

This is awesome

@Adewagold
Copy link

Awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment