Last active
November 15, 2017 07:41
-
-
Save fengtality/eb949b216b5c76b1151625dbeb38fec4 to your computer and use it in GitHub Desktop.
Sample code
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
contract Fund is Ownable { | |
Calculator calculator; | |
uint input1; | |
uint input2; | |
uint output; | |
function Fund (address _calculatorAddress) { | |
calculator = Calculator(_calculatorAddress); | |
} | |
function calculate() onlyOwner { | |
output = calculator.calculate(); | |
} | |
function setCalculator(address _calculatorAddress) onlyOwner returns (bool success) { | |
fund = Fund(_calculatorAddress); | |
return true; | |
} | |
} | |
contract Calculator is Ownable { | |
Fund fund; | |
function calculate() onlyFund constant returns (uint output) { | |
uint input1 = fund.input1(); | |
uint input2 = fund.input2(); | |
// Do something | |
return output; | |
} | |
function setFund(address _fundAddress) onlyOwner returns (bool success) { | |
fund = Fund(_fundAddress); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment