我想通过客户端的程序地址来获取锚点通常为任何已部署的 solana 程序生成的 IDL
这个怎么做?
更新:
我的错是我没有花时间正确研究这个问题,您可以使用这行代码const idl = await fetchIdl(programId);
来获取 idl 作为答案
我的 Anchor 程序有一个如下所示的指令结构:
#[derive(Accounts)]
pub struct MyInstruction<'info> {
pub my_account: Account<'info, MyAccount>,
// ...
}
#[account]
pub struct MyAccount {
// ... Many different fields
}
Run Code Online (Sandbox Code Playgroud)
当我尝试运行使用该结构的指令时,我收到一个奇怪的堆栈错误,如下所示:
Program failed to complete: Access violation in stack frame 3 at address 0x200003fe0 of size 8 by instruction #28386
Run Code Online (Sandbox Code Playgroud)
是什么赋予了?
当我尝试部署带有锚点的 IDL 时,我收到一条神秘的“自定义错误 0x1004”消息。这是什么意思:?
$ anchor idl init --provider.cluster testnet --filepath ./target/idl/myprogram.json sa3BafcCxwD6G3tUbvTcvnCD28sCXhpasauLtpw9HdA
Error: Error processing Instruction 0: custom program error: 0x1004
Run Code Online (Sandbox Code Playgroud) 我的 Anchor 程序抛出一个错误,如下所示:custom program error 0xa2
。这是什么意思?我在哪里可以了解此错误的含义?
我正在关注使用anchor(solana框架)的介绍教程,它基于官方github。在测试部分,我使用anchor test
命令并收到此错误:
BPF SDK: /home/sebastian/.local/share/solana/install/releases/1.9.12/solana-release/bin/sdk/bpf
cargo-build-bpf child: rustup toolchain list -v
cargo-build-bpf child: cargo +bpf build --target bpfel-unknown-unknown --release
Finished release [optimized] target(s) in 3.86s
cargo-build-bpf child: /home/sebastian/.local/share/solana/install/releases/1.9.12/solana-release/bin/sdk/bpf/dependencies/bpf-tools/llvm/bin/llvm-readelf --dyn-symbols /home/sebastian/Documentos/solana-project/anchor/examples/tutorial/basic-1/target/deploy/basic_1.so
To deploy this program:
$ solana program deploy /home/sebastian/Documentos/solana-project/anchor/examples/tutorial/basic-1/target/deploy/basic_1.so
The program address will default to this keypair (override with --program-id):
/home/sebastian/Documentos/solana-project/anchor/examples/tutorial/basic-1/target/deploy/basic_1-keypair.json
yarn run v1.22.17
$ /home/sebastian/Documentos/solana-project/anchor/examples/tutorial/node_modules/.bin/mocha -t 1000000 tests/
Error: Cannot find module '/home/sebastian/Documentos/solana-project/anchor/examples/tutorial/node_modules/@project-serum/anchor/dist/cjs/index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (node:internal/modules/cjs/loader:353:19)
at …
Run Code Online (Sandbox Code Playgroud) 我是区块链新手,我正在使用 solana/anchor/cargo/rust 来构建一个项目。我对这些命令感到困惑。cargo build
,cargo build-bpf
和有什么区别cargo build-sbf
?