From bd959674d6453308dacad3ce3cb2990a6317bc5b Mon Sep 17 00:00:00 2001 From: Tschakki Date: Thu, 21 Nov 2024 17:01:50 +0100 Subject: [PATCH] Add intro --- .../using-oracle-data/redstone-push.md | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/docs/building-on-lisk/using-oracle-data/redstone-push.md b/docs/building-on-lisk/using-oracle-data/redstone-push.md index 6857475e1..b099b945f 100644 --- a/docs/building-on-lisk/using-oracle-data/redstone-push.md +++ b/docs/building-on-lisk/using-oracle-data/redstone-push.md @@ -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`. @@ -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: @@ -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) \ No newline at end of file