Created
November 11, 2017 13:35
-
-
Save austintgriffith/31e959562f1a900a5cc1427706e63de2 to your computer and use it in GitHub Desktop.
Store
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.11; | |
contract Store is Ownable, Predecessor { | |
//string to hold source url of price information for reference | |
string public source; | |
//prices mapped by SYMBOL => price in USD | |
mapping (bytes32 => uint) price; | |
function Store(string _source) { | |
source = _source; | |
} | |
//only the owner can set prices by symbol | |
function setPrice(bytes32 _symbol,uint _price) onlyOwner { | |
//setPrice should never get called once a descendant is set | |
assert(descendant==address(0)); | |
price[_symbol]=_price; | |
} | |
//anyone can get any price by symbol | |
function getPrice(bytes32 _symbol) constant returns (uint) { | |
//if there is a descendant, pass the call on | |
if(descendant!=address(0)) { | |
return Store(descendant).getPrice(_symbol); | |
} | |
return price[_symbol]; | |
} | |
} | |
import 'zeppelin-solidity/contracts/ownership/Ownable.sol'; | |
import "Predecessor.sol"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment