sbv2-solana/examples/programs/anchor-vrf-parser
Conner Gallagher b576cfedeb uprev switchboard example deps 2022-08-04 08:54:51 -06:00
..
client refactor: moved programs and clients under examples 2022-07-22 12:11:29 -06:00
src Devnet feature flag and more account structs 2022-07-26 14:50:47 -06:00
tests updated spl-token to an npm alias 2022-08-03 15:36:38 -06:00
Cargo.toml updated spl-token to an npm alias 2022-08-03 15:36:38 -06:00
README.md refactor: moved programs and clients under examples 2022-07-22 12:11:29 -06:00
Xargo.toml refactor: moved programs and clients under examples 2022-07-22 12:11:29 -06:00
cli.ts [TS]: fix examples and Oracle.create 2022-08-03 17:12:53 -06:00
package.json uprev switchboard example deps 2022-08-04 08:54:51 -06:00
sbv2-vrf-example.sh refactor: moved programs and clients under examples 2022-07-22 12:11:29 -06:00
tsconfig.json refactor: moved programs and clients under examples 2022-07-22 12:11:29 -06:00

README.md

Switchboard VRF Cross Program Invocation Example

Example repo

Setup

npm i
find secrets/payer-keypair.json || solana-keygen new -s --no-bip39-passphrase --outfile secrets/payer-keypair.json
solana airdrop 1 secrets/payer-keypair.json
solana airdrop 1 secrets/payer-keypair.json
solana airdrop 1 secrets/payer-keypair.json
anchor build
solana-keygen pubkey target/deploy/anchor_vrf_example-keypair.json

Note the program ID.

In the following files, replace the program ID from above:

  • programs/anchor-vrf-example/src/lib.rs
  • Anchor.toml
  • solita.ts

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.

[provider]
cluster = "devnet"
wallet = "secrets/payer-keypair.json"

Then deploy and run the tests.

anchor test

Localnet Testing

In Anchor.toml, set the cluster to localnet.

[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