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
@@ -14,19 +14,34 @@ 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 a [Rust SDK](https://github.com/pyth-network/pyth-crosschain/tree/main/lazer/sdk/rust), which allows consumers to parse the price updates.
17
+
Pyth Lazer provides a [Solana SDK](https://docs.rs/pyth-lazer-solana-contract/latest/pyth_lazer_solana_contract/), which allows consumers to parse and verify the price updates on Solana-compatible chains.
18
18
19
-
Add the following to your `Cargo.toml` file:
19
+
To start, add the following to your `Cargo.toml` file (please check the current latest version at [crates.io](https://crates.io/crates/pyth-lazer-solana-contract)):
20
20
21
21
```toml copy
22
22
[dependencies]
23
-
pyth-lazer-sdk = 0.1.0
23
+
pyth-lazer-solana-contract = { version = "x.y.z", features = ["no-entrypoint"] }
24
24
```
25
25
26
26
Now you can create an instruction or multiple instructions that will receive Pyth Lazer messages.
27
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
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.
29
+
In order to successfully validate the Pyth Lazer message, the instruction needs to receive the following accounts:
30
+
31
+
- Fee payer account
32
+
- Pyth Lazer program account
33
+
- Pyth Lazer storage account
34
+
- Pyth Lazer treasury account
35
+
- The standard Solana system program account
36
+
- The standard Solana instructions sysvar account
37
+
38
+
You may also add any other accounts your contract needs.
39
+
40
+
<Callouttype="info"icon="💡">
41
+
The code snippets below are part of the full consumer contract example
Rust crate, which allows consumers to parse the price updates off-chain.
205
+
</Callout>
206
+
164
207
### Subscribe to Pyth Lazer to receive Price Updates
165
208
166
209
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.
@@ -171,6 +214,55 @@ Consult [How to fetch price updates from Pyth Lazer](../fetch-price-updates.mdx)
171
214
172
215
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.
173
216
217
+
In order to execute signature verification, you need to include an instruction for the built-in Solana ed25519 program in your transaction.
218
+
219
+
<Tabsitems={['Rust', 'JS']}>
220
+
<Tabs.Tab>
221
+
In Rust, you can leverage helpers provided in the `pyth_lazer_solana_contract` crate:
222
+
223
+
```rust copy
224
+
// Instruction #0 will be ed25519 instruction;
225
+
// Instruction #1 will be our contract instruction.
226
+
letinstruction_index=1;
227
+
// Total offset of Pyth Lazer update within the instruction data;
0 commit comments