Last active
October 19, 2022 09:42
-
-
Save ConsenSys-Academy/de1b2000f3682f0cfba784d0cb5400e7 to your computer and use it in GitHub Desktop.
Revisions
-
ConsenSys-Academy revised this gist
Aug 20, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ pragma solidity >=0.7.0 <0.9.0; contract Base { uint public num; -
ConsenSys-Academy revised this gist
Nov 3, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -19,11 +19,11 @@ contract FirstCaller { } 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)); } } -
ConsenSys-Academy revised this gist
Oct 25, 2019 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,8 +7,6 @@ contract Base { function setNum(uint _num) public { num = _num; sender = msg.sender; } } -
ConsenSys-Academy revised this gist
Oct 25, 2019 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,6 @@ contract Base { contract FirstCaller { uint public num; function setBaseNum(address _base, uint _num) public{ Base base = Base(_base); -
ConsenSys-Academy created this gist
Oct 25, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ pragma solidity ^0.5.0; contract Base { uint public num; address public sender; function setNum(uint _num) public { num = _num; sender = msg.sender; // msg.sender is FirstCaller if invoked by FirstCaller.callSetNum() or FirstCaller.setBaseNum() // msg.sender is SecondCaller if invoked by SecondCaller.callThrough() } } contract FirstCaller { uint public num; address public sender; 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); } }