open-index/open-npm huggingface dataset:
npm package: @pythnetwork/express-relay-evm-js
Description: Utilities for interacting with the express relay protocol
Author: Douro Labs
Latest version: 0.8.1
Deprecated: Please use '@pythnetwork/express-relay-js' instead.

# Pyth Express Relay JS SDK

Utility library for interacting with the Pyth Express Relay API.

## Installation

### npm

```
$ npm install --save @pythnetwork/express-relay-evm-js
```

### Yarn

```
$ yarn add @pythnetwork/express-relay-evm-js
```

## Development

To generate the latest type declarations from the server openapi schema, run:

```bash
npm run generate-api-types
```

## Quickstart

```typescript
import {
  Client,
  OpportunityParams,
  BidParams,
} from "@pythnetwork/express-relay-evm-js";

function calculateOpportunityBid(opportunity: Opportunity): BidParams | null {
  // searcher implementation here
  // if the opportunity is not suitable for the searcher, return null
}

async function bidStatusCallback(bidStatus: BidStatusUpdate) {
  console.log(`Bid status for bid ${bidStatus.id}: ${bidStatus.status.status}`);
}

async function opportunityCallback(opportunity: Opportunity) {
  const bidParams = calculateOpportunityBid(opportunity);
  if (bidParams === null) return;
  const opportunityBid = await client.signOpportunityBid(
    opportunity,
    bidParams,
    privateKey // searcher private key with appropriate permissions and assets
  );
  await client.submitOpportunityBid(opportunityBid);
}

const client = new Client(
  { baseUrl: "https://per-staging.dourolabs.app/" },
  bidStatusCallback,
  opportunityCallback
);

await client.subscribeChains([chain_id]); // chain id you want to subscribe to
```

### Example

There is an example searcher in [examples](./src/examples/) directory.

#### SimpleSearcher

[This example](./src/examples/simpleSearcher.ts) fetches `OpportunityParams` from the specified endpoint,
creates a fixed bid on each opportunity and signs them with the provided private key, and finally submits them back to the server. You can run it with
`npm run simple-searcher`. A full command looks like this:

```bash
npm run simple-searcher -- \
  --endpoint https://per-staging.dourolabs.app/ \
  --chain-id op_sepolia \
  --private-key <YOUR-PRIVATE-KEY>
```

Note that if you are using a localhost server at `http://127.0.0.1`, you should specify `--endpoint http://127.0.0.1:{PORT}` rather than `http://localhost:{PORT}`, as Typescript maps `localhost` to `::1` in line with IPv6 rather than to `127.0.0.1` as with IPv4.
npm package: @pythnetwork/express-relay-js
Description: Utilities for interacting with the express relay protocol
Author: Douro Labs
Latest version: 0.29.0

# Pyth Express Relay JS SDK

Utility library for interacting with the Pyth Express Relay API.

## Installation

### npm

```
$ npm install --save @pythnetwork/express-relay-js
```

### Yarn

```
$ yarn add @pythnetwork/express-relay-js
```

## Development

To generate the latest type declarations from the server openapi schema, run:

```bash
npm run generate-api-types
```

You can generate the SVM Typescript declaration files from the IDLs via:

```bash
npm run generate-anchor-types
```

## Quickstart

```typescript
import {
  Client,
  OpportunityParams,
  BidParams,
} from "@pythnetwork/express-relay-js";

function calculateOpportunityBid(opportunity: Opportunity): BidParams | null {
  // searcher implementation here
  // if the opportunity is not suitable for the searcher, return null
}

async function bidStatusCallback(bidStatus: BidStatusUpdate) {
  console.log(
    `Bid status for bid ${bidStatus.id}: ${JSON.stringify(bidStatus)}`,
  );
}

async function opportunityCallback(opportunity: Opportunity) {
  const bidParams = calculateOpportunityBid(opportunity);
  if (bidParams === null) return;
  const opportunityBid = await client.signOpportunityBid(
    opportunity,
    bidParams,
    privateKey, // searcher private key with appropriate permissions and assets
  );
  await client.submitOpportunityBid(opportunityBid);
}

const client = new Client(
  { baseUrl: "https://per-staging.dourolabs.app/" },
  bidStatusCallback,
  opportunityCallback,
);

await client.subscribeChains([chain_id]); // chain id you want to subscribe to
```

### Example

There is an example searcher in [examples](./src/examples/) directory.

#### SimpleSearcher

[This example](./src/examples/simpleSearcherEvm.ts) fetches `OpportunityParams` from the specified endpoint,
creates a fixed bid on each opportunity and signs them with the provided private key, and finally submits them back to the server. You can run it with
`npm run simple-searcher`. A full command looks like this:

```bash
npm run simple-searcher-evm -- \
  --endpoint https://per-staging.dourolabs.app/ \
  --chain-id op_sepolia \
  --private-key <YOUR-PRIVATE-KEY>
```

#### SimpleSearcherSvm

The SimpleSearcherSvm example submits a dummy SVM transaction to the auction server after appending the appropriate `SubmitBid` instruction that permissions the transaction. You can run it with `npm run simple-searcher-svm`, and the full command looks like:

```bash
npm run simple-searcher-svm -- \
  --endpoint-express-relay https://per-staging.dourolabs.app/ \
  --chain-id development-solana \
  --private-key <YOUR-PRIVATE-KEY> \
  --endpoint-svm "https://api.mainnet-beta.solana.com"
```

Note that if you are using a localhost server at `http://127.0.0.1`, you should specify `--endpoint http://127.0.0.1:{PORT}` rather than `http://localhost:{PORT}`, as Typescript maps `localhost` to `::1` in line with IPv6 rather than to `127.0.0.1` as with IPv4.
npm package: @pythnetwork/express-relay-sdk-solidity
Description: Solidity SDK for interacting with Express Relay contracts
Author: Douro Labs
Latest version: 0.2.0

# Express Relay Solidity SDK

## Install

### Truffle/Hardhat

If you are using Truffle or Hardhat, simply install the NPM package:

```bash
npm install @pythnetwork/express-relay-sdk-solidity
```

### Foundry

If you are using Foundry, you will need to create an NPM project if you don't already have one.
From the root directory of your project, run:

```bash
npm init -y
npm install @pythnetwork/express-relay-sdk-solidity
```

Then add the following line to your `remappings.txt` file:

```text
@pythnetwork/express-relay-sdk-solidity/=node_modules/@pythnetwork/express-relay-sdk-solidity
```
npm package: @pythnetwork/per-sdk-solidity
Description: Solidity SDK for interacting with Pyth express relay contracts
Author: Douro Labs
Latest version: 0.1.0

# Pyth Express Relay Solidity SDK

## Install

### Truffle/Hardhat

If you are using Truffle or Hardhat, simply install the NPM package:

```bash
npm install @pythnetwork/per-sdk-solidity
```

### Foundry

If you are using Foundry, you will need to create an NPM project if you don't already have one.
From the root directory of your project, run:

```bash
npm init -y
npm install @pythnetwork/per-sdk-solidity
```

Then add the following line to your `remappings.txt` file:

```text
@pythnetwork/per-sdk-solidity/=node_modules/@pythnetwork/per-sdk-solidity
```
npm package: @pythnetwork/price-service-sdk
Description: Pyth price service SDK
Latest version: 1.9.0

# Pyth SDK JS

The Pyth JavaScript SDK provides definitions and utilities for Pyth data structures.

Please see the [pyth.network documentation](https://docs.pyth.network/documentation/) for more information on how to use Pyth prices in various blockchains.

## Releases

We use [Semantic Versioning](https://semver.org/) for our releases. In order to release a new version of this package and publish it to npm, follow these steps:

1. Run `npm version <new version number> --no-git-tag-version`. This command will update the version of the package. Then push your changes to github.
2. Once your change is merged into `main`, create a release with tag `v<new version number>` like `v1.5.2`, and a github action will automatically publish the new version of this package to npm.
npm package: @pythnetwork/pyth-evm-js
Description: Pyth Network EVM Utils in JS
Author: Pyth Data Association
Latest version: 2.0.0

# Pyth EVM JS

[Pyth](https://pyth.network/) provides real-time pricing data in a variety of asset classes, including cryptocurrency,
equities, FX and commodities. This library allows you to use these real-time prices on EVM-based networks.

## Installation

### npm

```
$ npm install --save @pythnetwork/pyth-evm-js
```

### Yarn

```
$ yarn add @pythnetwork/pyth-evm-js
```

## Quickstart

### Filling Pyth Data for Transactions

The `fillPythUpdate` function helps you automatically determine what Pyth price updates are needed for a transaction and creates the necessary update call.
This function uses the `trace_callMany` method by default but can be used with `debug_traceCall` and a bundler as well. See the example below for more information.

```typescript
import { fillPythUpdate, multicall3Bundler, CallRequest } from "@pythnetwork/pyth-evm-js";
import { createPublicClient, http } from "viem";
import { optimismSepolia } from "viem/chains";

const PYTH_CONTRACT_OP_SEPOLIA = "0x0708325268df9f66270f1401206434524814508b"
const HERMES_ENDPOINT = "https://hermes.pyth.network"

const client = createPublicClient({
    chain: optimismSepolia,
    transport: http("YOUR_RPC_ENDPOINT"),
});

const call: CallRequest = {
    to: "0x3252c2F7962689fA17f892C52555613f36056f22",
    data: "0xd09de08a", // Your transaction calldata
    from: "0x78357316239040e19fC823372cC179ca75e64b81",
};

// Fill Pyth update data using "trace_callMany"
const pythUpdate = await fillPythUpdate(
    client,
    call,
    PYTH_CONTRACT_OP_SEPOLIA,
    HERMES_ENDPOINT,
    {
        method: "trace_callMany",
        maxIter: 5,
    },
);

// Fill Pyth update data using "debug_traceCall"
const _pythUpdateWithDebugTraceCall = await fillPythUpdate(
    client,
    call,
    PYTH_CONTRACT_OP_SEPOLIA,
    HERMES_ENDPOINT,
    {
        method: "debug_traceCall",
        bundler: multicall3Bundler, // or any function that takes a PythUpdate and a CallRequest and produces a CallRequest
        maxIter: 5,
    },
);

if (pythUpdate) {
    console.log("Pyth update needed:", pythUpdate);
    // Bundle the calls together, or pass the pythUpdate.updateData to your contract.
} else {
    console.log("No Pyth data needed for this transaction");
}
```
npm package: @pythnetwork/pyth-fuel-js
Description: Pyth Network Fuel Utils in JS
Author: Pyth Data Association
Latest version: 1.1.0

# Pyth Fuel JS

[Pyth](https://pyth.network/) provides real-time pricing data in a variety of asset classes, including cryptocurrency, equities, FX and commodities. This library allows you to use these real-time prices on Fuel network.

## Installation

### npm

```
$ npm install --save @pythnetwork/pyth-fuel-js
```

### Yarn

```
$ yarn add @pythnetwork/pyth-fuel-js
```

## Quickstart

This library is intended to be used in combination with `hermes-client` and `fuels`.

```
$ npm install --save fuels @pythnetwork/hermes-client
```

or

```
$ yarn add fuels @pythnetwork/hermes-client
```

Pyth stores prices off-chain to minimize gas fees, which allows us to offer a wider selection of products and faster update times.
See [On-Demand Updates](https://docs.pyth.network/documentation/pythnet-price-feeds/on-demand) for more information about this approach.
To use Pyth prices on chain,
they must be fetched from a Hermes instance. The `HermesClient` class from Pyth's `hermes-client` library can be used to interact with Hermes,
providing a way to fetch these prices directly in your code.
In order to use Pyth prices in your protocol you need to submit the price update data to Pyth contract in your target
chain.

For a complete example of how to obtain Pyth prices and submit them to a Fuel network, check out the [usage example](src/examples/usage.ts) in the `src/examples` directory.

We strongly recommend reading our guide which explains [how to work with Pyth price feeds](https://docs.pyth.network/documentation/pythnet-price-feeds/best-practices).