You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/data-streams/index.mdx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ One example of how to use Data Streams is in a decentralized exchange. An exampl
68
68
1. A user initiates a trade by confirming an `initiateTrade` transaction in their wallet.
69
69
1. The onchain contract for the decentralized exchange responds by emitting a Log Trigger event.
70
70
1. The Chainlink Automation upkeep monitors the contract for the event. When Automation detects the event, it runs the `checkLog` function specified in the upkeep contract. The upkeep is defined by the decentralized exchange.
71
-
1. The `checkLog` function uses a `revert` with a custom error called `StreamsLookup`. This approach, aligning with [EIP-3668](https://eips.ethereum.org/EIPS/eip-3668#use-of-revert-to-convey-call-information), conveys necessary information through the data in the `revert` custom error.
71
+
1. The `checkLog` function uses a `revert` with a custom error called `StreamsLookup`. This approach aligns with [EIP-3668](https://eips.ethereum.org/EIPS/eip-3668#use-of-revert-to-convey-call-information) and conveys the required information through the data in the `revert` custom error.
72
72
1. Chainlink Automation monitors the `StreamsLookup` custom error that triggers Chainlink Data Streams to process the offchain data request. Chainlink Data Streams then returns the requested signed report in the `checkCallback` function for Chainlink Automation.
73
73
1. Chainlink Automation passes the report to the Automation Registry, which executes the `performUpkeep` function defined by the decentralized exchange. The report is included as a variable in the `performUpkeep` function.
74
74
1. The `performUpkeep` function calls the `verify` function on the Data Streams onchain verifier contract and passes the report as a variable.
This guide shows you how to read data from a Data Stream and validate and store the answer onchain. This example uses a [Chainlink Automation Log Trigger](/chainlink-automation/guides/log-trigger) to check for events that require data. For this example, the log trigger comes from a simple emitter contract. Chainlink Automation then uses `StreamsLookup` to retrieve a signed report from the Data Streams Engine, return the data in a callback, and run the [`performUpkeep` function](/chainlink-automation/reference/automation-interfaces#performupkeep-function-for-log-triggers) on your registered upkeep contract. The `performUpkeep` function calls the `verify` function on the verifier contract.
3
+
This guide shows you how to read data from a Data Stream, validate the answer, and store the answer onchain. This example uses a [Chainlink Automation Log Trigger](/chainlink-automation/guides/log-trigger) to check for events that require data. For this example, the log trigger comes from a simple emitter contract. Chainlink Automation then uses `StreamsLookup` to retrieve a signed report from the Data Streams Engine, return the data in a callback, and run the [`performUpkeep` function](/chainlink-automation/reference/automation-interfaces#performupkeep-function-for-log-triggers) on your registered upkeep contract. The `performUpkeep` function calls the `verify` function on the verifier contract.
4
4
5
5
<Asidetype="caution"title="Disclaimer">
6
6
This guide represents an example of using a Chainlink product or service and is provided to help you understand how to
@@ -79,7 +79,7 @@ Deploy an upkeep contract that is enabled to retrieve data from Data Streams. Fo
79
79
80
80
## Deploy the emitter contract
81
81
82
-
This contract emits logs that trigger the upkeep. This code can be part of your dApp. For example, you might emit log triggers when your users initiate a trade or other action requiring data retrieval. For this Getting Started guide, we will use a very simple emitter so you can test the upkeep and data retrieval.
82
+
This contract emits logs that trigger the upkeep. This code can be part of your dApp. For example, you might emit log triggers when your users initiate a trade or other action requiring data retrieval. For this Getting Started guide, use a very simple emitter so you can test the upkeep and data retrieval.
83
83
84
84
1.[Open the LogEmitter.sol](https://remix.ethereum.org/#url=https://docs.chain.link/samples/DataStreams/LogEmitter.sol) contract in Remix.
85
85
@@ -95,7 +95,7 @@ This contract emits logs that trigger the upkeep. This code can be part of your
95
95
96
96
1. Open MetaMask and make sure the network is still set to _Arbitrum Sepolia_.
97
97
98
-
1.In Remix, under the **Deploy & Run Transactions** tab, ensure the **Environment** is still set to _Injected Provider - MetaMask_.
98
+
1.On the **Deploy & Run Transactions** tab in Remix, ensure the **Environment** is still set to _Injected Provider - MetaMask_.
@@ -175,15 +175,15 @@ Now, you can use your emitter contract to emit a log and initiate the upkeep, wh
175
175
176
176
1. Click the `emitLog` button to call the function and emit a log. MetaMask prompts you to accept the transaction.
177
177
178
-
After the transaction is complete, the log is emitted, and the upkeep is triggered. You can find the upkeep transaction hash at[Chainlink Automation UI](https://automation.chain.link/arbitrum-sepolia). Check to make sure the transaction is successful.
178
+
After the transaction is complete, the log is emitted, and the upkeep is triggered. You can find the upkeep transaction hash in the[Chainlink Automation UI](https://automation.chain.link/arbitrum-sepolia). Check to make sure the transaction is successful.
The retrieved price is stored as a variable in the contract and emitted in the logs.
185
185
186
-
1.In Remix, under the **Deploy & Run Transactions** tab, expand your upkeep contract in the **Deployed Contracts** section.
186
+
1.On the **Deploy & Run Transactions** tab in Remix, expand the details of your upkeep contract in the **Deployed Contracts** section.
187
187
188
188
1. Click the `last_retrieved_price` getter function to view the retrieved price. The answer on the ETH/USD feed uses 18 decimal places, so an answer of `248412100000000000` indicates an ETH/USD price of 2484.121. Each feed uses a different number of decimal places for answers. See the [Stream IDs](/data-streams/stream-ids) page for more information.
189
189
@@ -193,12 +193,12 @@ The retrieved price is stored as a variable in the contract and emitted in the l
193
193
style="max-width: 70%;"
194
194
/>
195
195
196
-
Alternatively, you can view the price emitted in the logs for your upkeep transaction. You can find the upkeep transaction hash at [Chainlink Automation UI](https://automation.chain.link/arbitrum-sepolia) and view the logs in the [Arbitrum Sepolia explorer](https://sepolia.arbiscan.io/).
196
+
Alternatively, you can view the price emitted in the logs for your upkeep transaction. You can find the upkeep transaction hash at [Chainlink Automation UI](https://automation.chain.link/arbitrum-sepolia) and view the transaction logs in the [Arbitrum Sepolia explorer](https://sepolia.arbiscan.io/).
197
197
198
198
## Examine the code
199
199
200
200
The example code you deployed has all the interfaces and functions required to work with Chainlink Automation as an upkeep contract. It follows a similar flow to the trading flow in the [Architecture](/data-streams#example-trading-flow) documentation but uses a basic log emitter to simulate the client contract that would initiate a `StreamsLookup`. After the contract receives and verifies the report, `performUpkeep` stores the price from the report in the `last_retrieved_price` and emits a `PriceUpdate` log message with the price. You could modify this to use the data in a way that works for your specific use case and application.
201
201
202
-
The code example uses `revert` with `StreamsLookup` to convey call information about what streams to retrieve. See the [eip-3668 rationale](https://eips.ethereum.org/EIPS/eip-3668#rationale) for more information on `revert` use in this way.
202
+
The code example uses `revert` with `StreamsLookup` to convey call information about what streams to retrieve. See the [EIP-3668 rationale](https://eips.ethereum.org/EIPS/eip-3668#rationale) for more information about how to use `revert` in this way.
0 commit comments