Skip to content

Commit 75159bb

Browse files
committed
Update Sol onchain integration
1 parent 000264d commit 75159bb

File tree

1 file changed

+34
-44
lines changed

1 file changed

+34
-44
lines changed

src/content/data-streams/tutorials/streams-direct/solana-onchain-report-verification.mdx

Lines changed: 34 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,23 @@ Before you begin, you should have:
7373

7474
To complete this guide, you'll need:
7575

76-
- **Rust and Cargo**: Install the latest version using [rustup](https://rustup.rs/). Run <CopyText text="rustc --version" code/> to verify your installation.
76+
- **Rust tool-chain ([rustup](https://rustup.rs/))**: Use `rustc` and `cargo` ≥ 1.73 (the version Anchor 0.31 requires). Run <CopyText text="rustc --version" code/> to verify your installation.
7777

78-
- **Solana CLI tools**: Install the latest version following the [official guide](https://docs.solana.com/cli/install-solana-cli-tools). Run <CopyText text="solana --version" code/> to verify your installation.
78+
- **Solana CLI tools**: Use 2.x (Anchor 0.31 is built against the 2.x SDK). Install an appropriate version following the [official guide](https://docs.solana.com/cli/install-solana-cli-tools). Run <CopyText text="solana --version" code/> to verify your installation.
7979

80-
- **Anchor Framework**: Follow the [official installation guide](https://www.anchor-lang.com/docs/installation). Run <CopyText text="anchor --version" code /> to verify your installation.
80+
- **Anchor Framework**: Use Anchor ≥ 0.31.0 (older 0.29/0.30 will not work with Solana 2.x.). Follow the [official installation guide](https://www.anchor-lang.com/docs/installation). Run <CopyText text="anchor --version" code /> to verify your installation.
8181

82-
- **Node.js and npm**: [Install Node.js 20 or later](https://nodejs.org/). Verify your installation with <CopyText text="node --version" code/>.
82+
- **Node.js and npm**: [Install Node.js ≥ 20](https://nodejs.org/). Verify your installation with <CopyText text="node --version" code/>.
8383

84-
- **ts-node**: Install globally using npm: <CopyText text="npm install -g ts-node" code/>. Verify your installation with <CopyText text="ts-node --version" code/>.
84+
- **ts-node**: Use ts-node ≥ 10. Install globally using npm: <CopyText text="npm install -g ts-node" code/>. Verify your installation with <CopyText text="ts-node --version" code/>.
8585

86-
- **Devnet SOL**: You'll need devnet SOL for deployment and testing. Use the [Solana CLI](https://docs.solana.com/cli/transfer-tokens#airdrop-some-tokens-to-get-started) or the [Solana Faucet](https://faucet.solana.com/) to get devnet SOL.
86+
- **Devnet SOL**: You'll need ~3-5 SOL in your devnet wallet for deployment and testing. Use the [Solana CLI](https://docs.solana.com/cli/transfer-tokens#airdrop-some-tokens-to-get-started) or the [Solana Faucet](https://faucet.solana.com/) to get devnet SOL.
8787

88-
> **Note**: While this guide uses the Anchor framework for project structure, you can integrate the verification using any Rust-based Solana program framework. The verifier SDK is written in Rust, but you can integrate it into your preferred Rust program structure.
88+
<Aside type="note" title="Framework agnostic">
89+
While this guide uses the Anchor framework for project structure, you can integrate the verification using any
90+
Rust-based Solana program framework. The verifier SDK is written in Rust, but you can integrate it into your preferred
91+
Rust program structure.
92+
</Aside>
8993

9094
### Implementation guide
9195

@@ -110,12 +114,14 @@ To complete this guide, you'll need:
110114
Open your `Anchor.toml` file at the root of your project and update it to use devnet:
111115

112116
```toml
117+
[toolchain]
118+
solana_version = "2.1.0"
119+
113120
[features]
114-
seeds = false
121+
resolution = true
115122
skip-lint = false
116123

117124
[programs.devnet]
118-
# Replace with your program ID
119125
example_verify = "<YOUR_PROGRAM_ID>"
120126

121127
[registry]
@@ -137,11 +143,11 @@ In your program's manifest file (`programs/example_verify/Cargo.toml`), add the
137143

138144
```toml
139145
[dependencies]
140-
chainlink_solana_data_streams = { git = "https://github.com/smartcontractkit/chainlink-data-streams-solana", subdir = "crates/chainlink-solana-data-streams" ,tag = "v1.1.0"}
141-
data-streams-report = { git = "https://github.com/smartcontractkit/data-streams-sdk.git", subdir = "rust/crates/report" }
146+
chainlink_solana_data_streams = { git = "https://github.com/smartcontractkit/chainlink-data-streams-solana", subdir = "crates/chainlink-solana-data-streams", tag = "v1.1.0" }
147+
chainlink-data-streams-report = "1.0.0"
142148

143149
# Additional required dependencies
144-
anchor-lang = "0.29.0"
150+
anchor-lang = { version = "0.31.0", features = ["idl-build"] }
145151
```
146152

147153
#### 4. Write the program
@@ -152,14 +158,13 @@ Navigate to your program main file (`programs/example_verify/src/lib.rs`). This
152158
// Import required dependencies for Anchor, Solana, and Data Streams
153159
use anchor_lang::prelude::*;
154160
use anchor_lang::solana_program::{
161+
instruction::Instruction,
155162
program::{get_return_data, invoke},
156163
pubkey::Pubkey,
157-
instruction::Instruction,
158164
};
159-
use data_streams_report::report::v3::ReportDataV3;
165+
use chainlink_data_streams_report::report::v3::ReportDataV3;
160166
use chainlink_solana_data_streams::VerifierInstructions;
161167

162-
163168
declare_id!("<YOUR_PROGRAM_ID>");
164169

165170
#[program]
@@ -253,7 +258,12 @@ Replace `<YOUR_PROGRAM_ID>` with your program ID in the `declare_id!` macro. You
253258

254259
Note how the `VerifierInstructions::verify` helper method automatically handles the PDA computations internally. Refer to the [Program Derived Addresses (PDAs)](#program-derived-addresses-pdas) section for more information.
255260

256-
> This example uses the [V3 schema](/data-streams/reference/report-schema) for [crypto streams](/data-streams/crypto-streams) to decode the report. If you verify reports for [RWA streams](/data-streams/rwa-streams), import and use the [V4 schema](/data-streams/reference/report-schema-v4) from the [report crate](https://github.com/smartcontractkit/data-streams-sdk/tree/main/rust/crates/report) instead.
261+
<Aside type="note" title="Report schema version">
262+
The report schema version is important for decoding the report data correctly. The example uses the [V3
263+
schema](/data-streams/reference/report-schema) for crypto streams. If you verify reports for RWA streams, use the [V4
264+
schema](/data-streams/reference/report-schema-v4) from the [report
265+
crate](https://github.com/smartcontractkit/data-streams-sdk/tree/main/rust/crates/report) instead.
266+
</Aside>
257267

258268
#### 5. Deploy your program
259269

@@ -263,20 +273,6 @@ Note how the `VerifierInstructions::verify` helper method automatically handles
263273
anchor build
264274
```
265275

266-
**Note**: If you run into this error, set the `version` field at the top of your `cargo.lock` file to `3`.
267-
268-
```bash
269-
warning: virtual workspace defaulting to `resolver = "1"` despite one or more workspace members being on edition 2021 which implies `resolver = "2"`
270-
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
271-
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
272-
note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions
273-
warning: .../example_verify/programs/example_verify/Cargo.toml: unused manifest key: dependencies.data-streams-report.subdir
274-
error: failed to parse lock file at: .../example_verify/Cargo.lock
275-
276-
Caused by:
277-
lock file version 4 requires `-Znext-lockfile-bump`
278-
```
279-
280276
1. Deploy your program to a Solana cluster (devnet in this example) using:
281277

282278
```bash
@@ -290,9 +286,9 @@ Note how the `VerifierInstructions::verify` helper method automatically handles
290286
Upgrade authority: ~/.config/solana/id.json
291287
Deploying program "example_verify"...
292288
Program path: ~/example_verify/target/deploy/example_verify.so...
293-
Program Id: 8XcUbDgY2UaUYNHkirKsWqXJtzPXezBSyj5Yh87dXums
289+
Program Id: ET4wvk16BozbiAyja89uHPGZxXzosyBFWcY6E6koCHxF
294290

295-
Signature: 3ky6VkpebDGq7x1n8JB32daybmjvbRBsD4yR2uCCussSWhokaEESTXuSa5s8NMvKTz2NZjoq9aoQ9pvuw9bYoibt
291+
Signature: FoFxJyWEYzwiA8k8W4mh4TC8EJicbvXKWjha2SGpD6EggXJWBRpKoHhiAtsuWJgN9pPDfyrfa92qCKmmPkvt9Ub
296292

297293
Deploy success
298294
```
@@ -303,10 +299,7 @@ In this section, you'll write a client script to interact with your deployed pro
303299

304300
1. In the `tests` directory, create a new file <CopyText text="verify_test.ts" code/> to interact with your deployed program.
305301

306-
1. Populate your `verify_tests.ts` file with the example client script below.
307-
308-
- Replace `<YOUR_PROGRAM_ID>` with your program ID.
309-
- This example provides a report payload. To use your own report payload, update the `hexString` variable.
302+
1. Populate your `verify_test.ts` file with the example client script below. This example provides a report payload. To use your own report payload, update the `hexString` variable.
310303

311304
```typescript
312305
import * as anchor from "@coral-xyz/anchor"
@@ -323,12 +316,9 @@ In this section, you'll write a client script to interact with your deployed pro
323316
const provider = anchor.AnchorProvider.env()
324317
anchor.setProvider(provider)
325318

326-
// Initialize your program using the IDL and your program ID
327-
const program = new Program<ExampleVerify>(
328-
require("../target/idl/example_verify.json"),
329-
"<YOUR_PROGRAM_ID>",
330-
provider
331-
)
319+
// Initialize the program using Anchor workspace - this automatically
320+
// loads the IDL and program ID from lib.rs (declare_id!)
321+
const program = anchor.workspace.ExampleVerify as Program<ExampleVerify>
332322

333323
// Convert the hex string to a Uint8Array
334324
// This is an example report payload for a crypto stream
@@ -455,15 +445,15 @@ In this section, you'll write a client script to interact with your deployed pro
455445
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
456446
🔑 Signer: 1BZZU8cJsrMSBaQQGUxTE4LQYX2SU2jjs97pkrz7rHD
457447
✅ Transaction successful!
458-
🔗 Signature: 2CTZ7kgAxTogvMgb7QFDJUAq9xFBUVTEvyjf7UuhoVrHDhYKtHpQmd8hEy9XvLhfgWMdVTpCRvdf18r1ixgtncUc
448+
🔗 Signature: 5wVCWAQUs7gZyCzbJDGs7UGHjbr3Z9YwyiV3PcpiJyKwZUVaUBf7BUAqX5CFGGfGWbBRu3PdfBRXCndeoeNPh4Ca
459449

460450
📋 Program Logs
461451
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
462452
📍 Instruction: Verify
463453
📍 Instruction: Verify
464454
📍 Report data found
465455
📍 FeedId: 0x0003684ea93c43ed7bd00ab3bb189bb62f880436589f1ca58b599cd97d6007fb
466-
📍 valid from timestamp: 1733758884
456+
📍 Valid from timestamp: 1733758884
467457
📍 Observations Timestamp: 1733758884
468458
📍 Native Fee: 84021511714900
469459
📍 Link Fee: 12978571827423900

0 commit comments

Comments
 (0)