README.md

This commit is contained in:
Conner Gallagher 2023-02-13 20:59:17 -07:00
parent 2c4d602f8a
commit 0d8065cba7
6 changed files with 133 additions and 76 deletions

View File

@ -47,6 +47,12 @@ git clone https://github.com/switchboard-xyz/sbv2-solana
| Mainnet-Beta | `SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f` | | Mainnet-Beta | `SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f` |
| Devnet | `2TfB33aLaneQb5TNVwyDz3jSZXS6jdW2ARw1Dgf84XCG` | | Devnet | `2TfB33aLaneQb5TNVwyDz3jSZXS6jdW2ARw1Dgf84XCG` |
See [switchboard.xyz/explorer](https://switchboard.xyz/explorer) for a list of
feeds deployed on Solana.
See [app.switchboard.xyz](https://app.switchboard.xyz) to create your own Solana
feeds.
## Libraries ## Libraries
| **Lang** | **Name** | **Description** | | **Lang** | **Name** | **Description** |

View File

@ -35,14 +35,14 @@ Build the example program
anchor build anchor build
``` ```
Get your program ID Get your program ID and update `Anchor.toml` and `src/lib.rs` with your pubkey
```bash ```bash
solana-keygen pubkey target/deploy/anchor_buffer_parser-keypair.json export ANCHOR_BUFFER_PARSER_PUBKEY=$(solana-keygen pubkey target/deploy/anchor_buffer_parser-keypair.json)
sed -i '' s/96punQGZDShZGkzsBa3SsfTxfUnwu4XGpzXbhF7NTgcP/"$ANCHOR_BUFFER_PARSER_PUBKEY"/g Anchor.toml
sed -i '' s/96punQGZDShZGkzsBa3SsfTxfUnwu4XGpzXbhF7NTgcP/"$ANCHOR_BUFFER_PARSER_PUBKEY"/g src/lib.rs
``` ```
Update `Anchor.toml` and `src/lib.rs` with your pubkey
Then run Anchor test Then run Anchor test
```bash ```bash

View File

@ -35,14 +35,14 @@ Build the example program
anchor build anchor build
``` ```
Get your program ID Get your program ID and update `Anchor.toml` and `src/lib.rs` with your pubkey
```bash ```bash
solana-keygen pubkey target/deploy/anchor_feed_parser-keypair.json export ANCHOR_FEED_PARSER_PUBKEY=$(solana-keygen pubkey target/deploy/anchor_feed_parser-keypair.json)
sed -i '' s/Fstf3oTcBxHMZFaoBzxk5oSkTh5HaAjxjh6zcgdZpNBb/"$ANCHOR_FEED_PARSER_PUBKEY"/g Anchor.toml
sed -i '' s/Fstf3oTcBxHMZFaoBzxk5oSkTh5HaAjxjh6zcgdZpNBb/"$ANCHOR_FEED_PARSER_PUBKEY"/g src/lib.rs
``` ```
Update `Anchor.toml` and `src/lib.rs` with your pubkey
Then run Anchor test Then run Anchor test
```bash ```bash

View File

@ -0,0 +1,50 @@
<div align="center">
<a href="#">
<img height="170" src="https://github.com/switchboard-xyz/sbv2-core/raw/main/website/static/img/icons/switchboard/avatar.svg" />
</a>
<h1>sbv2-solana / anchor-history-parser</h1>
<p>An example program written in Anchor demonstrating how to deserialize and read a Switchboard data feed's history buffer on Solana.</p>
<p>
<a href="https://crates.io/crates/switchboard-v2">
<img alt="Crates.io" src="https://img.shields.io/crates/v/switchboard-v2?label=switchboard-v2&logo=rust">
</a>
</p>
<p>
<a href="https://discord.gg/switchboardxyz">
<img alt="Discord" src="https://img.shields.io/discord/841525135311634443?color=blueviolet&logo=discord&logoColor=white">
</a>
<a href="https://twitter.com/switchboardxyz">
<img alt="Twitter" src="https://img.shields.io/twitter/follow/switchboardxyz?label=Follow+Switchboard" />
</a>
</p>
<h4>
<strong>Sbv2 Solana SDK: </strong><a href="https://github.com/switchboard-xyz/sbv2-solana">github.com/switchboard-xyz/sbv2-solana</a>
</h4>
</div>
## Usage
Build the example program
```bash
anchor build
```
Get your program ID and update `Anchor.toml` and `src/lib.rs` with your pubkey
```bash
export ANCHOR_HISTORY_PARSER_PUBKEY=$(solana-keygen pubkey target/deploy/anchor_history_parser-keypair.json)
sed -i '' s/C7rn1qJkq9FjTwV86RrY5Uih91NgymRVLdJ81rqLNXRS/"$ANCHOR_HISTORY_PARSER_PUBKEY"/g Anchor.toml
sed -i '' s/C7rn1qJkq9FjTwV86RrY5Uih91NgymRVLdJ81rqLNXRS/"$ANCHOR_HISTORY_PARSER_PUBKEY"/g src/lib.rs
```
Then run Anchor test
```bash
anchor test
```

View File

@ -1,78 +1,50 @@
# Switchboard VRF Cross Program Invocation Example <div align="center">
<a href="#">
<img height="170" src="https://github.com/switchboard-xyz/sbv2-core/raw/main/website/static/img/icons/switchboard/avatar.svg" />
</a>
Example repo <h1>sbv2-solana / anchor-vrf-parser</h1>
## Setup <p>An example program written in Anchor demonstrating how to deserialize and read a Switchboard VRF account on Solana.</p>
``` <p>
npm i <a href="https://crates.io/crates/switchboard-v2">
find secrets/payer-keypair.json || solana-keygen new -s --no-bip39-passphrase --outfile secrets/payer-keypair.json <img alt="Crates.io" src="https://img.shields.io/crates/v/switchboard-v2?label=switchboard-v2&logo=rust">
solana airdrop 1 secrets/payer-keypair.json </a>
solana airdrop 1 secrets/payer-keypair.json </p>
solana airdrop 1 secrets/payer-keypair.json
<p>
<a href="https://discord.gg/switchboardxyz">
<img alt="Discord" src="https://img.shields.io/discord/841525135311634443?color=blueviolet&logo=discord&logoColor=white">
</a>
<a href="https://twitter.com/switchboardxyz">
<img alt="Twitter" src="https://img.shields.io/twitter/follow/switchboardxyz?label=Follow+Switchboard" />
</a>
</p>
<h4>
<strong>Sbv2 Solana SDK: </strong><a href="https://github.com/switchboard-xyz/sbv2-solana">github.com/switchboard-xyz/sbv2-solana</a>
</h4>
</div>
## Usage
Build the example program
```bash
anchor build anchor build
solana-keygen pubkey target/deploy/anchor_vrf_parser-keypair.json
``` ```
Note the program ID. Get your program ID and update `Anchor.toml` and `src/lib.rs` with your pubkey
In the following files, replace the program ID from above: ```bash
export ANCHOR_VRF_PARSER_PUBKEY=$(solana-keygen pubkey target/deploy/anchor_vrf_parser-keypair.json)
- `programs/anchor-vrf-example/src/lib.rs` sed -i '' s/4wTeTACfwiXqqvy44bNBB3V2rFjmSTXVoEr4ZAYamJEN/"$ANCHOR_VRF_PARSER_PUBKEY"/g Anchor.toml
- `Anchor.toml` sed -i '' s/4wTeTACfwiXqqvy44bNBB3V2rFjmSTXVoEr4ZAYamJEN/"$ANCHOR_VRF_PARSER_PUBKEY"/g src/lib.rs
Rebuild the program `anchor build`.
## Devnet Testing
**NOTE:** Need to re-write test so use switchboard permissionless devnet queue
In `Anchor.toml`, set the cluster to devnet.
```toml
[provider]
cluster = "devnet"
wallet = "secrets/payer-keypair.json"
``` ```
Then deploy and run the tests. Then run Anchor test
``` ```bash
anchor test anchor test
``` ```
## Localnet Testing
In `Anchor.toml`, set the cluster to localnet.
```toml
[provider]
cluster = "localnet"
wallet = "secrets/payer-keypair.json"
```
Create a localnet switchboard environment
```
npx sbv2 localnet:env --keypair secrets/payer-keypair.json
```
In a new shell, start the local validator using the script output from above
```
chmod +x ./start-local-validator.sh
./start-local-validator.sh
```
In a new shell, start the local Switchboard oracle
```
chmod +x ./start-oracle.sh
CLUSTER=localnet ./start-oracle.sh
```
Run the anchor test using the already running localnet validator
```
anchor test --skip-local-validator
```

View File

@ -1,6 +1,35 @@
# On-Chain-Feed-Parser <div align="center">
<a href="#">
<img height="170" src="https://github.com/switchboard-xyz/sbv2-core/raw/main/website/static/img/icons/switchboard/avatar.svg" />
</a>
## Deploy <h1>sbv2-solana / native-feed-parser</h1>
<p>An example program written in native Rust demonstrating how to deserialize and read a Switchboard data feed on Solana.</p>
<p>
<a href="https://crates.io/crates/switchboard-v2">
<img alt="Crates.io" src="https://img.shields.io/crates/v/switchboard-v2?label=switchboard-v2&logo=rust">
</a>
</p>
<p>
<a href="https://discord.gg/switchboardxyz">
<img alt="Discord" src="https://img.shields.io/discord/841525135311634443?color=blueviolet&logo=discord&logoColor=white">
</a>
<a href="https://twitter.com/switchboardxyz">
<img alt="Twitter" src="https://img.shields.io/twitter/follow/switchboardxyz?label=Follow+Switchboard" />
</a>
</p>
<h4>
<strong>Sbv2 Solana SDK: </strong><a href="https://github.com/switchboard-xyz/sbv2-solana">github.com/switchboard-xyz/sbv2-solana</a>
</h4>
</div>
## Usage
Build the example program
```bash ```bash
cargo build-bpf --manifest-path=Cargo.toml cargo build-bpf --manifest-path=Cargo.toml