system_program_id
svm::system_program_id 返回 System Program 的 id,即 11111111111111111111111111111111。
default_pubkey
svm::default_pubkey 返回默认公钥,即 11111111111111111111111111111111。
get_instruction_data_from_idl_path
svm::get_instruction_data_from_idl_path 为程序调用创建编码后的 instruction data,并基于所提供的 IDL 文件进行类型检查和序列化。
输入
| 名称 | 是否必需 | 类型 | 描述 |
|---|---|---|---|
idl_path | 必需 | string | IDL .json 文件的路径,相对于 txtx.yml |
instruction_name | 必需 | string | 要为其生成数据的指令名称 |
arguments | 可选 | array[string] | 要为其生成数据的指令参数 |
c3f1b80e7f9b4435,即 sha256("global:my_instruction") 的前 8 个字节)以及经过 Borsh 编码的参数组成:每个字符串由 4 字节小端序长度和其 UTF-8 字节构成。
get_instruction_data_from_idl
svm::get_instruction_data_from_idl 为程序调用创建编码后的 instruction data,并基于所提供的 IDL 数据进行类型检查和序列化。
输入
| 名称 | 是否必需 | 类型 | 描述 |
|---|---|---|---|
idl | 必需 | string | SVM_IDL | 程序 IDL |
instruction_name | 必需 | string | 要为其生成数据的指令名称,以 IDL 中的索引为准 |
arguments | 可选 | array[string] | 要为其生成数据的指令参数 |
get_program_from_anchor_project
svm::get_program_from_anchor_project 从 Anchor 项目中获取程序的部署工件。
输入
| 名称 | 是否必需 | 类型 | 描述 |
|---|---|---|---|
program_name | 必需 | string | 要部署的程序名称 |
keypair_path | 可选 | string | 程序 keypair 文件的位置 |
idl_path | 可选 | string | 程序 IDL 文件的位置 |
bin_path | 可选 | string | 程序二进制文件的位置 |
get_program_from_native_project
svm::get_program_from_native_project 获取非 Anchor 程序的部署工件。
输入
| 名称 | 是否必需 | 类型 | 描述 |
|---|---|---|---|
program_name | 必需 | string | 要部署的程序名称 |
keypair_path | 可选 | string | 程序 keypair 文件的位置 |
idl_path | 可选 | string | 程序 IDL 文件的位置 |
bin_path | 可选 | string | 程序二进制文件的位置 |
sol_to_lamports
svm::sol_to_lamports 将所提供的 SOL 数量转换为 lamports。
lamports_to_sol
svm::lamports_to_sol 将所提供的 lamports 数量转换为 SOL。
find_pda
svm::find_pda 使用所提供的程序 id 和 seeds 查找有效的 PDA。
输入
| 名称 | 是否必需 | 类型 | 描述 |
|---|---|---|---|
program_id | 必需 | string | 派生该 PDA 的程序地址 |
seeds | 可选 | array[string] | 可选的 seeds 数组(最多 16 个,每个 32 字节) |
get_associated_token_account
svm::get_associated_token_account 根据所提供的钱包地址和代币 mint 地址,计算 associated token account 的地址。
输入
| 名称 | 是否必需 | 类型 | 描述 |
|---|---|---|---|
wallet_address | 必需 | string | 钱包地址 |
token_mint_address | 可选 | string | 代币 mint 地址 |
create_token_account_instruction
svm::create_token_account_instruction 创建用于创建 associated token account 的原始指令字节。
输入
| 名称 | 是否必需 | 类型 | 描述 |
|---|---|---|---|
funding_address | 必需 | string | 出资账户的地址 |
wallet_address | 必需 | string | 钱包地址 |
token_mint_address | 可选 | string | 代币 mint 地址 |
token_program_id | 可选 | string | Token Program 的地址 |
u64
svm::u64 创建 u64 整数的字节数组表示,适合在 PDA 派生中用作 seed。
输入
| 名称 | 是否必需 | 类型 | 描述 |
|---|---|---|---|
value | 必需 | integer | 要转换为字节数组的 u64 整数 |
i64
svm::i64 创建 i64 整数的字节数组表示,适合在 PDA 派生中用作 seed。
输入
| 名称 | 是否必需 | 类型 | 描述 |
|---|---|---|---|
value | 必需 | integer | 要转换为字节数组的 i64 整数 |