Skip to content

Instantly share code, notes, and snippets.

@EtDu
Created March 22, 2020 05:08
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 EtDu/3ef9f0e1b720fc7d14cb19a14e076606 to your computer and use it in GitHub Desktop.
Save EtDu/3ef9f0e1b720fc7d14cb19a14e076606 to your computer and use it in GitHub Desktop.
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