Skip to content

Instantly share code, notes, and snippets.

@Sohailghafoor
Created April 4, 2022 11:19
Show Gist options
  • Save Sohailghafoor/1b6ba2564b9c7a6cce7e966e290a98cd to your computer and use it in GitHub Desktop.
Save Sohailghafoor/1b6ba2564b9c7a6cce7e966e290a98cd to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract B {
uint public num;
address public sender;
uint public value;
function setVars(uint _num) public payable {
num = _num;
sender = msg.sender;
value = msg.value;
}
}
contract A {
uint public num;
address public sender;
uint public value;
function setVars(address _contract, uint _num) public payable {
(bool success, bytes memory data) = _contract.delegatecall(
abi.encodeWithSignature("setVars(uint256)", _num)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment