Created
February 19, 2018 20:44
-
-
Save sogoiii/0a474f024194cb5e9e3b2f9183a27c78 to your computer and use it in GitHub Desktop.
This file contains 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
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