Skip to content

Instantly share code, notes, and snippets.

@td-bn
Created November 2, 2021 15:29
Show Gist options
  • Save td-bn/710705cb7d4442524722164acdf230e5 to your computer and use it in GitHub Desktop.
Save td-bn/710705cb7d4442524722164acdf230e5 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: MIT
pragma solidity >=0.7.0 <0.9.0;
contract Store {
uint public num;
function setNum(uint _num) public {
num = _num;
}
}
contract StoreAndSet {
uint public constant num = 42;
uint public oops = 60;
function delegateStoreNum(address _store, uint _num) public {
(bool success, bytes memory data) = _store.delegatecall(
abi.encodeWithSignature("setNum(uint256)", _num)
);
require(success);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment