Skip to content

Instantly share code, notes, and snippets.

@shingonu
Created December 11, 2018 15:08
Show Gist options
  • Save shingonu/c737b52e3242dc56e971afd3073cba36 to your computer and use it in GitHub Desktop.
Save shingonu/c737b52e3242dc56e971afd3073cba36 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.24;
contract D {
function callSetN(address _e, uint _n) public {
_e.call.value(10).gas(6712353)(bytes4(keccak256("setN(uint256)")), _n);
// E's storage is set, D is not modified
}
function callcodeSetN(address _e, uint _n) public {
_e.callcode.value(10).gas(6712353)(bytes4(keccak256("setN(uint256)")), _n);
// D's storage is set, E is not modified
}
function delegatecallSetN(address _e, uint _n) public {
_e.delegatecall.gas(6712353)(bytes4(keccak256("setN(uint256)")), _n);
// D's storage is set, E is not modified
}
}
contract E {
uint public n;
address public sender;
uint256 public amount;
function setN(uint _n) {
n = _n;
sender = msg.sender;
amount = msg.value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment