Skip to content

Instantly share code, notes, and snippets.

@alofeoluwafemi
Created October 7, 2022 13:58
Show Gist options
  • Save alofeoluwafemi/b76e7e86cb82f5f6ad54fcc2a1545f44 to your computer and use it in GitHub Desktop.
Save alofeoluwafemi/b76e7e86cb82f5f6ad54fcc2a1545f44 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "./Oracle.sol";
contract PriceConsumer {
Oracle public oracleAddress;
uint public price;
function requestKlayPrice(
Oracle _oracleAddress,
string memory _adapterId
) external returns(bool) {
oracleAddress = _oracleAddress;
oracleAddress.newOracleRequest(this.setKLAYUSD.selector, _adapterId, address(this));
return true;
}
function setKLAYUSD(
uint _price
) external {
require(msg.sender == address(oracleAddress),"Consumer: Permission Denied");
price = _price;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment