Interacting With Chainlink Contracts
From Chainlink Community Wiki
How to Query Chainlink Contracts
This page will provide you with information regarding how to query a Chainlink Aggregator
Included are some examples using bash.
All examples are based on the LINK / USD price feed on Ethereum Mainnet
Overview
Each Chainlink Aggregator has a wide range of data that you can query.
From historic price data to the timestamp of the most recent completed round, a lot of information is stored on-chain and available for you to query.
This page will be broken out into each major contract type, and then each individual query that can be made, with examples.
EACAggregatorProxy
LINK / USD EAC AggregatorProxy contract address: 0x2c1d072e956affc0d435cb7ac38ef18d24d9127c
The Access Controlled Aggregator Proxy is a proxy contract that enables the owner to point it to other contracts as needed/desired.
This prevents the users from having to update anything if they wanted to move to a new contract version/release
Read Calls
accessController
The accessController is a smart contract that acts as a whitelist for which addresses are able to call the contract. For the LINK / USD price feed, the referenced accessController smart contract is a null value set to 0x0000000000000000000000000000000000000000
aggregator
The aggregator is the on-chain contract that each of the Chainlink Nodes responds to. The AggregatorProxy contract points to the configured Aggregator as it's primary source of information
decimals
The decimals value tells the reader of the contract how many decimal places they need to adjust to get the proper value.
For example, if the LINK / USD price feed has a decimlas value of 8, and the latest round shows a response of 726792272, then we would shift the decimal 8 places to end with a value of 7.26792272.
description
The Desctiption of the Proxy is just a friendly name, in this case displaying LINK / USD
getAnswer
This call will provide you with the data for the round you have specified.
getRoundData
Similar to the above getAnswer call, this call will get additional information from the round you have specified.
getTimestamp
This getTimestamp call will provide you with the timestamp of the block containing the data from the round you have specified.
latestAnswer
The latestAnswer call provides you with the value that was written to chain during the most recent completed round
latestRound
This call will provide you with the most recent completed round number.
latestRoundData
This call is similar to getRoundData, but it will automatically get the round data for the most recently completed round.
latestTimestamp
Similar to latestRoundData and getTimestamp, the latestTimestamp call will provide you with the timestamp of the block containing the response from the latest completed round.
owner
The owner query will respond with the address that has ownership of the contract you query.
phaseAggregators
phaseId
proposedAggregator
The proposedAggregator query will give you the address of the proposed aggregator, if there is one.
proposedGetRoundData
This call provides you with the round data for the requested round from the proposed aggregator, if there is one.
proposedLatestRoundData
Similar to the above, this call will get you the data from the latest round of the proposed aggregator.
version
This gets you the version of the contract you're querying.