Created
March 22, 2020 05:08
-
-
Save EtDu/3ef9f0e1b720fc7d14cb19a14e076606 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
constructor () public payable { | |
landlordAddress = msg.sender; | |
provable_setCustomGasPrice(100000000000); | |
OAR = OracleAddrResolverI(0xB7D2d92e74447535088A32AD65d459E97f692222); | |
} | |
function fetchUsdRate() internal { | |
require(provable_getPrice("URL") < address(this).balance, "Not enough Ether in contract, please add more"); | |
bytes32 queryId = provable_query("URL", "json(https://api.pro.coinbase.com/products/ETH-USD/ticker).price"); | |
validIds[queryId] = true; | |
} | |
function __callback(bytes32 myId, string memory result) public { | |
require(validIds[myId], "Provable query IDs do not match, no valid call was made to provable_query()"); | |
require(msg.sender == provable_cbAddress(), "Calling address does match usingProvable contract address "); | |
validIds[myId] = false; | |
ETHUSD = parseInt(result); | |
if (workingState == State.payingLeaseDeposit) { | |
_payLeaseDeposit(); | |
} else if (workingState == State.payingLease) { | |
_payLease(); | |
} else if (workingState == State.collectingLeaseDeposit) { | |
_collectLeaseDeposit(); | |
} else if (workingState == State.reclaimingLeaseDeposit) { | |
_reclaimLeaseDeposit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment