Skip to content

Instantly share code, notes, and snippets.

@alexroan
Last active March 25, 2021 12:22
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 alexroan/902e40cbf5d0a2f583ce2ceb0b9c7749 to your computer and use it in GitHub Desktop.
Save alexroan/902e40cbf5d0a2f583ce2ceb0b9c7749 to your computer and use it in GitHub Desktop.
KrakenConsumer.sol
pragma solidity ^0.6.0;
import "https://raw.githubusercontent.com/smartcontractkit/chainlink/master/evm-contracts/src/v0.6/ChainlinkClient.sol";
/**
* DO NOT USE IN PRODUCTION!!
* THIS IS EXAMPLE CONTRACT FOR THE KOVAN TESTNET
*/
contract KrakenConsumer is ChainlinkClient {
address private oracle;
bytes32 private jobId;
uint256 private fee;
uint256 public currentPrice;
/**
* Network: Kovan
* Chainlink - 0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e
* Kraken - 8f4eeda1a8724077a0560ee84eb006b4
* Fee: 1 LINK
*/
constructor() public {
setPublicChainlinkToken();
oracle = 0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e;
jobId = "8f4eeda1a8724077a0560ee84eb006b4";
fee = 1 * 10 ** 18; // 1 LINK
}
function requestPrice() public {
Chainlink.Request memory req = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
req.add("index", "DEFI_KXBTUSD");
req.addInt("times", 100);
sendChainlinkRequestTo(oracle, req, fee);
}
function fulfill(bytes32 _requestId, uint256 _price) public
recordChainlinkFulfillment(_requestId)
{
currentPrice = _price;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment