Created
September 21, 2020 03:58
-
-
Save cNoveron/cfe64b513059f55a7096c5433e8ba110 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.6.0+commit.26b70077.js&optimize=false&gist=
This file contains hidden or 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
/** This example code is designed to quickly deploy an example contract using Remix. | |
* If you have never used Remix, try our example walkthrough: https://docs.chain.link/docs/example-walkthrough | |
* You will need testnet ETH and LINK. | |
* - Ropsten ETH faucet: https://faucet.ropsten.be/ | |
* - Ropsten LINK faucet: https://ropsten.chain.link/ | |
*/ | |
pragma solidity ^0.6.0; | |
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.6/ChainlinkClient.sol"; | |
contract ChainlinkTest is ChainlinkClient { | |
address private oracle; | |
bytes32 private jobId; | |
uint256 private fee; | |
uint256 public ethereumPrice; | |
/** | |
* Network: Kovan | |
* Oracle: | |
* Name: LinkPool | |
* Listing URL: https://market.link/nodes/323602b9-3831-4f8d-a66b-3fb7531649eb | |
* Address: 0x83dA1beEb89Ffaf56d0B7C50aFB0A66Fb4DF8cB1 | |
* Job: | |
* Name: Get > Uint256 | |
* Listing URL: https://market.link/jobs/0609deab-6d61-4937-85e4-a8e810b8b272 | |
* ID: b6602d14e4734c49a5e1ce19d45a4632 | |
* Fee: 0.1 LINK | |
*/ | |
constructor() public { | |
setPublicChainlinkToken(); | |
oracle = 0x56dd6586DB0D08c6Ce7B2f2805af28616E082455; // oracle address | |
jobId = "b6602d14e4734c49a5e1ce19d45a4632"; //job id | |
fee = 0.1 * 10 ** 18; // 0.1 LINK | |
} | |
/** | |
* Make initial request | |
*/ | |
function initialRequest() public { | |
Chainlink.Request memory req = buildChainlinkRequest(jobId, address(this), this.fulfillOracleRequest.selector); | |
sendChainlinkRequestTo(oracle, req, fee); | |
} | |
/** | |
* Callback function | |
*/ | |
function fulfillOracleRequest(bytes32 _requestId, uint256 _price) public recordChainlinkFulfillment(_requestId) { | |
ethereumPrice = _price; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment