INTRODUCTION Tutorials Beginners - The Basics Intermediates - Random Numbers Advanced - API Calls Architecture Overview Basic Request Model Decentralized Data Model Off-Chain Reporting
USING PRICE FEEDS Introduction to Price Feeds Get the Latest Price Historical Price Data API Reference Contract Addresses ENS Ethereum Price Feeds Binance Smart Chain Price Feeds Polygon (Matic) Price Feeds xDai Price Feeds Huobi Eco Chain Price Feeds Avalanche Price Feeds
USING CHAINLINK KEEPERS Introduction Making Compatible Contracts Register Upkeep for a Contract Network Overview
USING ANY API Introduction to Using Any API Make a GET Request Make an Existing Job Request Find Existing Jobs API Reference Contract Addresses
DEVELOPER REFERENCE Install Instructions LINK Token Contracts Developer Communications Hackathon Resources User Guides Install, configure & fund MetaMask Acquire testnet LINK Deploy your first contract Fund your contract Use your first contract!
Use your first contract!
- Navigate back to Remix.
- On the left side panel you will see a list of functions of your contract.
- In our example contract there are 3 functions that you can use to request external data from Chainlink.
- For this example we will use
- In the input field to the right of
requestEthereumPrice, copy the text below to request the price of ETH in United States Dollars. The first parameter is the oracle contract address, and the second parameter is the Job ID. You will need to include the quotes.
- Click on the
- MetaMask will pop-up to confirm the transaction, click Confirm. (If you get a gas estimation failed message here, make sure the contract is funded with LINK./)
- Once the transaction confirms, you can visit the Kovan Chainlink Explorer in order to view the status of your request. Search for either the address of your contract or your requesting transaction ID and you should see an update from the Chainlink node. You can refresh the page to keep up-to-date with the status, and when the response is confirmed, you can view the result in your contract.
- To verify that your request was fulfilled, click on the blue
currentPricebutton. If the value after
0then the request has not be fulfilled yet. Wait a little longer since the Chainlink node will wait for 3 block confirmations before fulfilling your request. Otherwise, it will show you the current price of ETH multiplied by 100. This weird looking output is by design, as the ETH protocol cannot display decimal values. In our example, the
33495which represents $334.95 USD.
If you see a value for the
currentPrice variable, then Chainlink has successfully responded to your contract with the current price of ETH. Now you're ready to write more complex smart contracts that execute based on real-world data.