|
1 |
| -# agent |
2 |
| -Publish and observe data on the Pyth Network |
| 1 | +# Pyth Agent |
| 2 | +Publish data to the [Pyth Network](https://pyth.network/). |
| 3 | + |
| 4 | +## Overview |
| 5 | +This software runs a JRPC API server, which data providers should use to publish data. Publishing using this intermediate API server provides greater reliability, usability and security than sending transactions directly to an RPC node. |
| 6 | + |
| 7 | +Note that only permissioned publishers can publish data to the network. Please read the [publisher guidelines](https://docs.pyth.network/publish-data) before getting started. |
| 8 | + |
| 9 | +## Build |
| 10 | + |
| 11 | +Prerequisites: Rust 1.68 or higher. A Unix system is recommended. |
| 12 | + |
| 13 | +```bash |
| 14 | +# Install OpenSSL |
| 15 | +apt install libssl-dev |
| 16 | + |
| 17 | +# Build the project. This will produce a binary at target/release/agent |
| 18 | +cargo build --release |
| 19 | +``` |
| 20 | + |
| 21 | +## Configure |
| 22 | +Configuration is managed through a configuration file. An example configuration file with sensible defaults can be found at [config/config.toml](config/config.toml). |
| 23 | + |
| 24 | +The logging level can be configured at runtime through the `RUST_LOG` environment variable, using [env_logger](https://docs.rs/env_logger/latest/env_logger/)'s scheme. For example, to log at `debug` instead of the default `info` level, set `RUST_LOG=debug`. |
| 25 | + |
| 26 | +## Run |
| 27 | + |
| 28 | +### Key Store |
| 29 | +If you already have a key store set up, you can skip this step. If you haven't, you will need to create one before publishing data. A key store contains the cryptographic keys needed to publish data. Once you have a key store set up, please ensure that the configuration file mentioned above contains the correct path to your key store. |
| 30 | + |
| 31 | +```bash |
| 32 | +# Install the Solana Tool Suite, needed for creating the key used to sign your transactions. |
| 33 | +sh -c "$(curl -sSfL https://release.solana.com/v1.14.13/install)" |
| 34 | + |
| 35 | +# Create the key store directory. This can be any location that is convenient for you. |
| 36 | +PYTH_KEY_STORE=$HOME/.pythd |
| 37 | + |
| 38 | +# Create your keypair (pair of private/public keys) that will be used to sign your transactions. |
| 39 | +solana-keygen new --no-bip39-passphrase --outfile $PYTH_KEY_STORE/publish_key_pair.json |
| 40 | + |
| 41 | +# Initialize the key store with the public keys of the Pyth Oracle Program on the network you wish to publish to. |
| 42 | +PYTH_KEY_ENV=devnet # Can be devnet, testnet or mainnet |
| 43 | +./scripts/init_key_store.sh $PYTH_KEY_ENV $PYTH_KEY_STORE |
| 44 | +``` |
| 45 | + |
| 46 | +### API Server |
| 47 | +```bash |
| 48 | +# Run the agent binary, which will start a JRPC websocket API server. |
| 49 | +./target/release/agent --config config/config.toml |
| 50 | +``` |
| 51 | + |
| 52 | +### Publish Data |
| 53 | +You can now publish data to the Pyth Network using the JRPC websocket API documented [here](https://docs.pyth.network/publish-data/pyth-client-websocket-api). |
0 commit comments