Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pythnetwork/client

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pythnetwork/client - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

6

CHANGELOG.md
# Changelog
## 1.0.6
### Changed
Updated README.md
## 1.0.5

@@ -4,0 +10,0 @@

2

package.json
{
"name": "@pythnetwork/client",
"version": "1.0.5",
"version": "1.0.6",
"description": "Pyth price oracle data structures",

@@ -5,0 +5,0 @@ "homepage": "https://pyth.network",

@@ -1,2 +0,2 @@

# pyth-client-js
# @pythnetwork/client

@@ -11,22 +11,38 @@ ## A library for parsing on-chain Pyth oracle data

## Installation
### npm
```
$ npm install --save @pythnetwork/client
```
### Yarn
```
$ yarn add @pythnetwork/client
```
## Example Usage
```
```javascript
import { Connection, PublicKey } from '@solana/web3.js'
import { parseMappingData, parsePriceData, parseProductData } from '@pythnetwork/pyth-client'
import { parseMappingData, parsePriceData, parseProductData } from '@pythnetwork/client'
const connection = new Connection(SOLANA_CLUSTER_URL)
const publicKey = new PublicKey(ORACLE_MAPPING_PUBLIC_KEY)
connection.getAccountInfo(publicKey).then((accountInfo) => {
const { productAccountKeys } = parseMappingData(accountInfo.data)
connection.getAccountInfo(productAccountKeys[productAccountKeys.length - 1]).then((accountInfo) => {
const { product, priceAccountKey } = parseProductData(accountInfo.data)
connection.getAccountInfo(priceAccountKey).then((accountInfo) => {
const { price, confidence } = parsePriceData(accountInfo.data)
console.log(`${product.symbol}: $${price} \xB1$${confidence}`)
// SRM/USD: $8.68725 ±$0.0131
})
const publicKey = new PublicKey(ORACLE_MAPPING_PUBLIC_KEY)
connection.getAccountInfo(publicKey).then((accountInfo) => {
const { productAccountKeys } = parseMappingData(accountInfo.data)
connection.getAccountInfo(productAccountKeys[productAccountKeys.length - 1]).then((accountInfo) => {
const { product, priceAccountKey } = parseProductData(accountInfo.data)
connection.getAccountInfo(priceAccountKey).then((accountInfo) => {
const { price, confidence } = parsePriceData(accountInfo.data)
console.log(`${product.symbol}: $${price} \xB1$${confidence}`)
// SRM/USD: $8.68725 ±$0.0131
})
})
})
```
To get streaming price updates, you may want to use `connection.onAccountChange`
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc