2023-03-13 10:45:51 -07:00
# Solana program for receiving price VAA from Pythnet
2023-02-15 07:43:51 -08:00
2023-03-13 10:45:51 -07:00
The program under `cli` receives a VAA string from the shell, verifies the VAA with wormhole, posts the VAA on solana and then invokes the receiver program under `programs` .
The receiver program verifies that the VAA comes from wormhole (through the `owner` function in `state.rs` ) and deserializes the price information (in `decode_posted_vaa` function of `lib.rs` ).
2023-02-15 07:43:51 -08:00
2023-03-13 10:45:51 -07:00
```shell
# Generate the program key
# and use the key to replace the following two places
2023-11-30 13:04:41 -08:00
# "pyth-solana-receiver" in Anchor.toml
# "declare_id!()" in programs/pyth-solana-receiver/src/lib.rs
2023-03-13 10:45:51 -07:00
> solana-keygen new -o program_address.json
# Build and deploy the receiver program
2023-11-30 13:04:41 -08:00
> anchor build -- features devnet # use --features mainnet for mainnet
2023-03-13 10:45:51 -07:00
> anchor run deploy
# Build and test the cli program
2023-11-30 13:04:41 -08:00
> anchor run cli_build_devnet
> anchor run cli_test_devnet
2023-03-13 10:45:51 -07:00
# Example output
...
[1/5] Decode the VAA
[2/5] Get wormhole guardian set configuration
[3/5] Invoke wormhole on solana to verify the VAA
Transaction successful : 3VbrqQBCf1RsNLxrcvxN3aTb5fZRht4n8XDUVPM8NKniRmo84NZQUu5iFw5groAQgQYox3YCqaMjKc2WTpPU1yqV
[4/5] Post the VAA data onto a solana account
Transaction successful : 3L1vxzSHQv6B6TwtoMv2Y6m7vFGz3hzqApGHEhHSLA9Jn5dNKeWRWKv29UDPDc3vsgt1mYueamUPPt6bHGGEkbxh
[5/5] Receive and deserialize the VAA on solana
Receiver program ID is 5dXnHcDXdXaiEp9QgknCDPsEhJStSqZqJ4ATirWfEqeY
Transaction successful : u5y9Hqc18so3BnjSUvZkLZR4mvA8zkiBgzGKHSEYyWkHQhH3uQatM7xWf4kdrhjZFVGbfBLdR8RJJUmuf28ePtG
```
2023-04-05 10:44:45 -07:00
## Unit tests
Run `anchor run test` to run the unit tests in the `src/tests/` directory.
**Warning**: do not confuse this command with `anchor test` , which doesn't do anything useful.