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: pages/lazer/integrate-as-consumer/svm.mdx
+159-4Lines changed: 159 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,21 +14,176 @@ Integrating with Pyth Lazer in smart contracts as a consumer is a three-step pro
14
14
15
15
### Use Pyth Lazer SDK into smart contracts
16
16
17
-
Pyth Lazer provides [pyth-lazer-sdk]() crate, which allows consumers to parse the price updates.
17
+
Pyth Lazer provides a [Rust SDK](https://github.com/pyth-network/pyth-crosschain/tree/main/lazer/sdk/rust), which allows consumers to parse the price updates.
18
+
19
+
Add the following to your `Cargo.toml` file:
20
+
21
+
```toml copy
22
+
[dependencies]
23
+
pyth-lazer-sdk = 0.1.0
24
+
```
25
+
26
+
Now you can create an instruction or multiple instructions that will receive Pyth Lazer messages.
27
+
The instruction data sent to your program should include a byte array containing the Pyth Lazer message. The instruction data can also contain any other parameters your contracts may need.
28
+
29
+
In order to successfully validate the Pyth Lazer message, the instruction needs to receive the standard Solana sysvar account and Pyth Lazer storage account (`3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL`). You may also add any other accounts you need.
30
+
31
+
The following code can be used to set up a new instruction within a Solana contract:
### Subscribe to Pyth Lazer to receive Price Updates
165
+
166
+
Pyth Lazer provides a websocket endpoint to receive price updates. Moreover, Pyth Lazer also provides a [typescript SDK](https://github.com/pyth-network/pyth-crosschain/tree/main/lazer/sdk/js) to subscribe to the websocket endpoint.
167
+
168
+
Consult [How to fetch price updates from Pyth Lazer](../fetch-price-updates.mdx) for a complete step-by-step guide.
169
+
170
+
### Include the price updates into smart contract transactions
171
+
172
+
Now that you have the price updates, and your smart contract is able to parse the price updates, you can include the price updates into the smart contract transactions by passing the price updates received from the previous step as an argument to the `update_price` method of your smart contract.
18
173
19
174
</Steps>
20
175
21
176
## Additional Resources
22
177
23
-
You may find these additional resources helpful for integrating Pyth Lazer into your EVM smart contracts.
178
+
You may find these additional resources helpful for integrating Pyth Lazer into your Solana smart contracts.
24
179
25
180
### Price Feed IDs
26
181
27
182
Pyth Lazer supports a wide range of price feeds. Consult the [Price Feed IDs](../price-feeds.mdx) page for a complete list of supported price feeds.
28
183
29
184
### Examples
30
185
31
-
[Pyth-lazer-example-evm](https://github.com/pyth-network/pyth-examples/tree/main/lazer/evm) is a simple example contract that parses and consumes price updates from Pyth Lazer.
186
+
[pyth-lazer-example-solana](https://github.com/pyth-network/pyth-examples/tree/main/lazer/solana) is a simple example contract that parses and consumes price updates from Pyth Lazer.
32
187
33
188
[pyth-lazer-example-js](https://github.com/pyth-network/pyth-examples/tree/main/lazer/js) is a simple example for subscribing to the Pyth Lazer websocket.
0 commit comments