Skip to content

Commit

Permalink
Merge branch 'liskdocs-12-redstone-push' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Tschakki committed Nov 21, 2024
2 parents 6dadc41 + bd95967 commit 13b0404
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions docs/building-on-lisk/using-oracle-data/redstone-push.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,32 @@ This page will explain how you can access oracle data using [Redstone Push](http

RedStone is a data ecosystem that delivers frequently updated, reliable, and diverse data for your dApp and smart contracts deployed on Lisk.

RedStone data feeds are compatible with Chainlinks [AggregatorV3Interface](https://docs.chain.link/data-feeds/using-data-feeds#solidity) and include the following components:

- **Aggregator contract**: An aggregator is a contract that receives periodic data updates from the oracle network.
Aggregators store aggregated data onchain so that consumers can retrieve it and act upon it within the same transaction.
These contracts are already deployed on the Lisk network and can be directly used by Consumers.
- **Consumer**: A consumer is an onchain or offchain application that uses Data Feeds.
Consumer contracts use the `AggregatorV3Interface` to call functions on the proxy contract[^1] of the Aggregator to retrieve oracle data.

[^1]: Proxy contracts are onchain proxies that point to the aggregator for a particular data feed.
Using proxies enables the underlying aggregator to be upgraded without any service interruption to consuming contracts.

## Data feeds on Lisk
The following Aggregators are available on Lisk Mainnet for Redstone Push:

- [ETH/USD L2PriceFeedWithoutRounds](https://blockscout.lisk.com/address/0x6b7AB4213c77A671Fc7AEe8eB23C9961fDdaB3b2)
- address: `0x6b7AB4213c77A671Fc7AEe8eB23C9961fDdaB3b2`
- [LSK/USD L2PriceFeedWithoutRounds](https://blockscout.lisk.com/address/0xa1EbA9E63ed7BA328fE0778cFD67699F05378a96)
- address: `0xa1EbA9E63ed7BA328fE0778cFD67699F05378a96`
- [USDT/USD L2PriceFeedWithoutRounds](https://blockscout.lisk.com/address/0xd2176Dd57D1e200c0A8ec9e575A129b511DBD3AD)
- address: `0xd2176Dd57D1e200c0A8ec9e575A129b511DBD3AD`

In this guide, we will develop a Consumer contract, that will request the latest spot prices from all the above data feeds.

## Import

To use the RedStone data in your contract, import the [AggregatorV3Interface](https://docs.chain.link/data-feeds/using-data-feeds#solidity) from Chainlink.
To use the RedStone data inside your contract, import the [AggregatorV3Interface](https://docs.chain.link/data-feeds/using-data-feeds#solidity) from Chainlink like shown in the example contract below.

For every data feed you like to store, create a new constant with type `AggregatorV3Interface`.

Expand Down Expand Up @@ -84,7 +106,7 @@ To read the data of the price feeds, we define the following functions in the co
- `getRedStoneLSKDataFeedLatestAnswer()`
- `getRedStoneUSDTDataFeedLatestAnswer()`

Inside of the functions, call the [latestRoundData](https://docs.chain.link/data-feeds/api-reference#latestrounddata) on the respective price feeds to receive the latest price feeds for the respective token.
Inside of the functions, call the [latestRoundData](https://docs.chain.link/data-feeds/api-reference#latestrounddata) on the respective data feeds to receive the latest spot prices for the respective token.

The `latestRoundData()` function returns the following values:

Expand Down Expand Up @@ -187,3 +209,10 @@ contract DataConsumerV3 {
}
}
```

## Deploying on Lisk

To deploy the smart contract on Lisk, follow the guides

- [Deploying a smart contract with Hardhat](../deploying-smart-contract/with-Hardhat), or
- [Deploying a smart contract with Foundry](../deploying-smart-contract/with-Foundry)

0 comments on commit 13b0404

Please sign in to comment.