Skip to content

Instantly share code, notes, and snippets.

@sogoiii
Created February 19, 2018 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sogoiii/0a474f024194cb5e9e3b2f9183a27c78 to your computer and use it in GitHub Desktop.
Save sogoiii/0a474f024194cb5e9e3b2f9183a27c78 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.18;
contract Worker1 {
uint public n;
address public sender;
function setN(uint _n) public {
n = _n;
sender = msg.sender;
}
}
contract Worker2 {
uint public n;
address public sender;
function setN2(uint _n) public {
n = _n * 2;
sender = msg.sender;
}
}
contract Factory {
address worker;
function updateWorker(address _w) public {
worker = _w;
}
function getWorker() view public returns (address) {
return worker;
}
function doWork(uint _val, string fnName) public {
worker.call(bytes4(keccak256(fnName)), _val);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment