Actions

Interacting With Chainlink Contracts: Difference between revisions

From Chainlink Community Wiki

No edit summary
Line 18: Line 18:


=== '''EACAggregatorProxy''' ===
=== '''EACAggregatorProxy''' ===
'''LINK / USD EAC AggregatorProxy contract address: [https://etherscan.io/address/0x2c1d072e956affc0d435cb7ac38ef18d24d9127c#readContract 0x2c1d072e956affc0d435cb7ac38ef18d24d9127c]'''
'''LINK / USD EACAggregatorProxy contract address: [https://etherscan.io/address/0x2c1d072e956affc0d435cb7ac38ef18d24d9127c#readContract 0x2c1d072e956affc0d435cb7ac38ef18d24d9127c]'''


The Access Controlled Aggregator Proxy is a proxy contract that enables the owner to point it to other contracts as needed/desired.
The Access Controlled Aggregator Proxy is a proxy contract that enables the owner to point it to other contracts as needed/desired.
Line 24: Line 24:
This prevents the users from having to update anything if they wanted to move to a new contract version/release
This prevents the users from having to update anything if they wanted to move to a new contract version/release


==== '''Read Calls''' ====
==== '''[[EACAggregatorProxy Reads|Read Calls]]''' ====
----
The Read calls are queries you can make to each <code>EACAggregatorProxy</code> to get a wide range of data from the proxy's associated <code>AccessControlledOffchainAggregator</code> contract.  One such example is to get the latest round data from a price feed.
 
===== '''accessController''' =====
The <code>accessController</code> 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 <code>accessController</code> smart contract is a null value set to <code>0x0000000000000000000000000000000000000000</code>


* Example Query:
==== [[EACAggregatorProxy Writes|'''Write Calls''']] ====
** <code>ACCESS_CONTROLLER=$(curl -s -H "Content-Type: application/json" https://'''$YOUR_RPC_ENDPOINT''' -d '{"jsonrpc": "2.0", "id": 123, "method": "eth_call", "params":[{"from":null,"to":"0x2c1d072e956AFFC0D435Cb7AC38EF18d24d9127c","data":"0xbc43cbaf"}, "latest"]}' | jq -r .result) && echo "$ACCESS_CONTROLLER"</code>
The Write calls that are available to each <code>EACAggregatorProxy</code> are used to make changes to the contract. An example of a write call would be to change the associated <code>AccessControlledOffchainAggregator</code>


* Example Response:
** <code>0x0000000000000000000000000000000000000000000000000000000000000000</code>
***(remove leading 24 <code>0</code>'s)
----
----


===== '''aggregator''' =====
=== '''AccessControlledOffchainAggregator''' ===
The <code>aggregator</code> is the on-chain contract that each of the Chainlink Nodes responds to. The <code>AggregatorProxy</code> contract points to the configured Aggregator as it's primary source of information
'''LINK / USD AccessControlledOffchainAggregator contract address: [https://etherscan.io/address/0xdfd03bfc3465107ce570a0397b247f546a42d0fa#code 0xDfd03BfC3465107Ce570a0397b247F546a42D0fA]'''


*Example Query:
The Access Controlled Offchain Aggregator is the aggregator contract that the Chainlink Nodes report to.
** <code>AGGREGATOR=$(curl -s -H "Content-Type: application/json" https://'''$YOUR_RPC_ENDPOINT''' -d '{"jsonrpc": "2.0", "id": 123, "method": "eth_call", "params":[{"from":null,"to":"0x2c1d072e956AFFC0D435Cb7AC38EF18d24d9127c","data":"0x245a7bfc"}, "latest"]}' | jq -r .result) && echo "$AGGREGATOR"</code>


* Example Response:
This is the contract that contains the on-chain information that is read by the <code>EACAggregatorProxy</code>
** <code>0x000000000000000000000000dfd03bfc3465107ce570a0397b247f546a42d0fa</code>
***(remove leading 24 <code>0</code>'s)
----


===== '''decimals''' =====
==== '''Read Calls''' ====
The <code>decimals</code> value tells the reader of the contract how many decimal places they need to adjust to get the proper value.
blah
 
For example, if the <code>LINK / USD</code> price feed has a decimlas value of <code>8</code>, and the latest round shows a response of <code>726792272</code>, then we would shift the decimal 8 places to end with a value of <code>7.26792272</code>.
 
* Example Query:
** <code>DECIMALS=$(curl -s -H "Content-Type: application/json" https://'''$YOUR_RPC_ENDPOINT''' -d '{"jsonrpc": "2.0", "id": 123, "method": "eth_call", "params":[{"from":null,"to":"0x2c1d072e956AFFC0D435Cb7AC38EF18d24d9127c","data":"0x313ce567"}, "latest"]}' | jq -r .result) && echo "$((DECIMALS))"</code>
* Example Response:
** <code>8</code>
 
----
 
===== '''description''' =====
The <code>desctiption</code> of the Proxy is just a friendly name, in this case displaying LINK / USD
 
* Example Query:
** <code>DESCRIPTION=$(curl -s -H "Content-Type: application/json" https://'''$YOUR_RPC_ENDPOINT''' -d '{"jsonrpc": "2.0", "id": 123, "method": "eth_call", "params":[{"from":null,"to":"0x2c1d072e956AFFC0D435Cb7AC38EF18d24d9127c","data":"0x7284e416"}, "latest"]}' | jq -r .result) && echo $DESCRIPTION | xxd -r -p</code>
 
* Example Response:
** <code>LINK / USD</code>
 
----
 
===== '''getAnswer''' =====
This call will provide you with the data for the round you have specified.
 
* Example Query:
** <code>curl</code>
* Example Response
** asdf
 
----
 
===== '''getRoundData''' =====
Similar to the above <code>getAnswer</code> call, this call will get additional information from the round you have specified.
 
* Example Query:
** <code>curl</code>
* Example Response
** asdf
 
----
 
===== '''getTimestamp''' =====
This <code>getTimestamp</code> call will provide you with the timestamp of the block containing the data from the round you have specified.
 
* Example Query:
** <code>curl</code>
* Example Response
** asdf
 
===== '''latestAnswer''' =====
The <code>latestAnswer</code> call provides you with the value that was written to chain during the most recent completed round
 
* Example Query:
** <code>curl</code>
* Example Response
** asdf
 
===== '''latestRound''' =====
This call will provide you with the most recent completed round number.
 
* Example Query:
** <code>curl</code>
* Example Response
** asdf
 
===== '''latestRoundData''' =====
This call is similar to <code>getRoundData</code>, but it will automatically get the round data for the most recently completed round.
 
* Example Query:
** <code>curl</code>
* Example Response
** asdf
 
===== '''latestTimestamp''' =====
Similar to <code>latestRoundData</code> and <code>getTimestamp</code>, the <code>latestTimestamp</code> call will provide you with the timestamp of the block containing the response from the latest completed round.
 
* Example Query:
** <code>curl</code>
* Example Response
** asdf
 
===== '''owner''' =====
The owner query will respond with the address that has ownership of the contract you query.
 
* Example Query:
** <code>curl</code>
* Example Response
** asdf
 
===== '''phaseAggregators''' =====
 
===== '''phaseId''' =====
 
===== '''proposedAggregator''' =====
The <code>proposedAggregator</code> query will give you the address of the proposed aggregator, if there is one.
 
* Example Query:
** <code>curl</code>
* Example Response
** asdf
 
===== '''proposedGetRoundData''' =====
This call provides you with the round data for the requested round from the proposed aggregator, if there is one.
 
* Example Query:
** <code>curl</code>
* Example Response
** asdf
 
===== '''proposedLatestRoundData''' =====
Similar to the above, this call will get you the data from the latest round of the proposed aggregator.
 
* Example Query:
** <code>curl</code>
* Example Response
** asdf
 
===== '''version''' =====
This gets you the version of the contract you're querying.


* Example Query:
==== '''Write Calls''' ====
** <code>curl</code>
blah
* Example Response
** asdf

Revision as of 14:15, 24 May 2022

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 EACAggregatorProxy 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

The Read calls are queries you can make to each EACAggregatorProxy to get a wide range of data from the proxy's associated AccessControlledOffchainAggregator contract. One such example is to get the latest round data from a price feed.

Write Calls

The Write calls that are available to each EACAggregatorProxy are used to make changes to the contract. An example of a write call would be to change the associated AccessControlledOffchainAggregator


AccessControlledOffchainAggregator

LINK / USD AccessControlledOffchainAggregator contract address: 0xDfd03BfC3465107Ce570a0397b247F546a42D0fA

The Access Controlled Offchain Aggregator is the aggregator contract that the Chainlink Nodes report to.

This is the contract that contains the on-chain information that is read by the EACAggregatorProxy

Read Calls

blah

Write Calls

blah