Created
September 13, 2022 02:46
-
-
Save casweeney/b6e4c0f6b413eb9c2eed41bb593fbe85 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
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.4; | |
| contract B { | |
| uint public num; | |
| address public sender; | |
| uint public amount; | |
| address public sender2; | |
| string public name; | |
| function setFirstAndLast(uint _num, string memory _name) external { | |
| num = _num; | |
| name = _name; | |
| } | |
| function setOtherThree(uint _amount) external { | |
| sender = msg.sender; | |
| amount = _amount; | |
| sender2 = msg.sender; | |
| } | |
| } | |
| contract A { | |
| uint public num; | |
| address public sender; | |
| uint public amount; | |
| address public sender2; | |
| string public name; | |
| function setFirstAndLast(address _contract, uint _num, string memory _name) external { | |
| (bool success, bytes memory data) = _contract.delegatecall(abi.encodeWithSignature("setFirstAndLast(uint256,string)", _num, _name)); | |
| require(success, "delegatecall failed"); | |
| } | |
| function setOtherThree(address _contract, uint _amount) external { | |
| (bool success, bytes memory data) = _contract.delegatecall(abi.encodeWithSignature("setOtherThree(uint256)", _amount)); | |
| require(success, "delegatecall failed"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment