@@ -10,22 +10,24 @@ See our [examples repo](https://github.com/pyth-network/pyth-examples) for real-
10
10
11
11
## Example Usage
12
12
13
- ```
13
+ ``` javascript
14
14
import { Connection , PublicKey } from ' @solana/web3.js'
15
- import { parseMappingData, parsePriceData, parseProductData } from '@pythnetwork/pyth-client'
15
+ import { parseMappingData , parsePriceData , parseProductData } from ' @pythnetwork/client'
16
+
16
17
const connection = new Connection (SOLANA_CLUSTER_URL )
17
- const publicKey = new PublicKey(ORACLE_MAPPING_PUBLIC_KEY)
18
- connection.getAccountInfo(publicKey).then((accountInfo) => {
19
- const { productAccountKeys } = parseMappingData(accountInfo.data)
20
- connection.getAccountInfo( productAccountKeys[productAccountKeys.length - 1]).then(( accountInfo) => {
21
- const { product, priceAccountKey } = parseProductData( accountInfo.data)
22
- connection.getAccountInfo( priceAccountKey).then((accountInfo) => {
23
- const { price, confidence } = parsePriceData(accountInfo.data)
24
- console.log(`${product.symbol}: $${ price} \xB1$${ confidence}` )
25
- // SRM/USD : $8.68725 ±$0.0131
26
- })
18
+ const publicKey = new PublicKey (ORACLE_MAPPING_PUBLIC_KEY )
19
+
20
+ connection . getAccountInfo (publicKey). then (( accountInfo ) => {
21
+ const { productAccountKeys } = parseMappingData ( accountInfo . data )
22
+ connection . getAccountInfo (productAccountKeys[ productAccountKeys . length - 1 ]). then (( accountInfo ) => {
23
+ const { product , priceAccountKey } = parseProductData ( accountInfo . data )
24
+ connection . getAccountInfo (priceAccountKey). then (( accountInfo ) => {
25
+ const { price , confidence } = parsePriceData ( accountInfo . data )
26
+ console . log ( ` ${ product . symbol } : $${ price } \xB1 $ ${ confidence } ` )
27
+ // SRM/USD: $8.68725 ±$0.0131
27
28
})
28
29
})
30
+ })
29
31
```
30
32
31
33
To get streaming price updates, you may want to use ` connection.onAccountChange `
0 commit comments