Skip to content

Commit 8a78f2a

Browse files
authored
An example contract for Solana and the Anchor library (#82)
1 parent 75e2742 commit 8a78f2a

File tree

11 files changed

+3341
-0
lines changed

11 files changed

+3341
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
yarn.lock
2+
Cargo.lock
3+
.anchor
4+
.DS_Store
5+
target
6+
**/*.rs.bk
7+
node_modules
8+
test-ledger
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[programs.devnet]
2+
example_sol_anchor_contract = "Fwn1fCmbjd8d95hxY9NUUr5Xa7D13khveMnmCUFdd3ah"
3+
4+
[provider]
5+
cluster = "devnet"
6+
wallet = "~/.config/solana/id.json"
7+
8+
[scripts]
9+
install = "npm install"
10+
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 scripts/test.ts"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[workspace]
2+
members = [
3+
"programs/*"
4+
]
5+
6+
[profile.release]
7+
overflow-checks = true
8+
lto = "fat"
9+
codegen-units = 1
10+
[profile.release.build-override]
11+
opt-level = 3
12+
incremental = false
13+
codegen-units = 1
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Pyth SDK Example Program for Solana and the Anchor Library
2+
3+
This example implements the same functionalities as the `sol-contract` example.
4+
The difference is that this example uses the `anchor` library while the `sol-contract` example uses the lower-level solana interface.
5+
Please refer to the README of `sol-contract` for a description of the functionalities.
6+
7+
## Run this program
8+
We assume that you have installed `anchor`, `npm` and `yarn`.
9+
10+
```shell
11+
# Generate the program key
12+
> solana-keygen new -o program_address.json
13+
14+
# Use the pubkey generated to replace the following two places
15+
# "example_sol_anchor_contract" in Anchor.toml
16+
# "declare_id!()" in programs/example-sol-anchor-contract/src/lib.rs
17+
18+
# Enter the directory and build this example
19+
> cd examples/sol-contract-anchor
20+
> anchor build
21+
22+
# Change the `wallet` field in Anchor.toml to your own wallet
23+
# And then deploy the example contract; An error may occur if
24+
# your wallet does not have enough funds
25+
> anchor deploy --program-keypair program_address.json --program-name example-sol-anchor-contract
26+
27+
# Install the client dependencies and invoke this program
28+
> anchor run install
29+
> anchor run invoke
30+
```

0 commit comments

Comments
 (0)