INTRODUCTION Tutorials The Basics Random Numbers API Calls Other Tutorials Architecture Overview Basic Request Model Decentralized Data Model Off-Chain Reporting
USING DATA FEEDS Introduction to Data Feeds Get the Latest Price (EVM) Get the Latest Price (Solana) Historical Price Data Feed Registry API Reference Contract Addresses ENS Ethereum Data Feeds Binance Smart Chain Data Feeds Polygon (Matic) Data Feeds xDai Data Feeds Huobi Eco Chain Data Feeds Avalanche Data Feeds Fantom Data Feeds Arbitrum Data Feeds Harmony Data Feeds Solana Data Feeds Optimism Data Feeds
USING RANDOMNESS Introduction to Chainlink VRF Get a Random Number API Reference Security Considerations Contract Addresses Best Practices
USING CHAINLINK KEEPERS Introduction Making Compatible Contracts Register Upkeep for a Contract Patterns and Best Practices Network Overview FAQs
USING ANY API Introduction to Using Any API Make a GET Request Make an Existing Job Request Multi-Variable Responses Large Responses Find Existing Jobs API Reference Contract Addresses
DEVELOPER REFERENCE Install Instructions LINK Token Contracts Developer Communications Getting Help Data Provider Nodes Hackathon Resources Contributing to Chainlink User Guides Install, configure & fund MetaMask Acquire testnet LINK Deploy your first contract Fund your contract Use your first contract!
Use your first contract!
Executing Functions
- 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.
requestEthereumChange
,requestEthereumLastMarket
andrequestEthereumPrice
- For this example we will use
requestEthereumPrice
. - 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.
"0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e", "29fa9aa13bf1468788b7cc4a500a45b8
"0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e","ad752d90098243f8a5c91059d3e5616c"
"0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e","50fc4215f89443d185b061e5d7af9490"
- Click on the
requestEthereumPrice
button.
- 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./)
- The transaction confirmation will take some time. When the response is confirmed, you can view the result in your contract.
- To verify that your request was fulfilled, click on the blue
currentPrice
button. If the value afteruint256
displays0
then 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, thecurrentPrice
returned33495
which 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.