Deze functies zijn beschikbaar wanneer u de SVM-addon gebruikt voor Solana en SVM-compatibele blockchains.
system_program_id
svm::system_program_id geeft het id van het System Program terug,
11111111111111111111111111111111.
output "system_program_id" {value = svm::system_program_id()}// > 11111111111111111111111111111111
default_pubkey
svm::default_pubkey geeft een standaard publieke sleutel (pubkey) terug,
11111111111111111111111111111111.
output "default_pubkey" {value = svm::default_pubkey()}// > 11111111111111111111111111111111
get_instruction_data_from_idl_path
svm::get_instruction_data_from_idl_path maakt gecodeerde instruction data aan
voor een programma-aanroep, met typecontrole en serialisatie op basis van het
opgegeven IDL-bestand.
Invoer
| Name | Required | Type | Description |
|---|---|---|---|
idl_path | required | string | Het pad, relatief aan de txtx.yml, naar het IDL .json bestand |
instruction_name | required | string | De naam van de instructie waarvoor data gegenereerd moet worden |
arguments | optional | array[string] | De instructie-argumenten waarvoor data gegenereerd moet worden |
output "data" {value = svm::get_instruction_data_from_idl("/path/to/idl.json", "my_instruction", ["arg1", "arg2"])}// > data: 0x95763bdcc47fa1b305000000776f726c64
get_instruction_data_from_idl
svm::get_instruction_data_from_idl maakt gecodeerde instruction data aan voor
een programma-aanroep, met typecontrole en serialisatie op basis van de
opgegeven IDL-gegevens.
Invoer
| Name | Required | Type | Description |
|---|---|---|---|
idl | required | string | SVM_IDL | De IDL van het programma |
instruction_name | required | string | De naam van de instructie waarvoor data gegenereerd moet worden, zoals geïndexeerd in de IDL |
arguments | optional | array[string] | De instructie-argumenten waarvoor data gegenereerd moet worden |
output "data" {value = svm::get_instruction_data_from_idl(variable.contract.idl, "my_instruction", ["arg1", "arg2"])}// > data: 0x95763bdcc47fa1b305000000776f726c64
get_program_from_anchor_project
svm::get_program_from_anchor_project haalt de implementatieartefacten op voor
een programma in een Anchor-project.
Invoer
| Naam | Verplicht | Type | Beschrijving |
|---|---|---|---|
program_name | verplicht | string | De naam van het programma dat wordt geïmplementeerd |
keypair_path | optioneel | string | De locatie van het keypair-bestand van het programma |
idl_path | optioneel | string | De locatie van het IDL-bestand van het programma |
bin_path | optioneel | string | De locatie van het binaire bestand van het programma |
variable "contract" {value = svm::get_program_from_anchor_project("my_program")}output "idl" {value = variable.contract.idl}
get_program_from_native_project
svm::get_program_from_native_project haalt de implementatie-artefacten op voor
een niet-Anchor-programma.
Invoer
| Naam | Verplicht | Type | Beschrijving |
|---|---|---|---|
program_name | verplicht | string | De naam van het programma dat wordt geïmplementeerd |
keypair_path | optioneel | string | De locatie van het keypair-bestand van het programma |
idl_path | optioneel | string | De locatie van het IDL-bestand van het programma |
bin_path | optioneel | string | De locatie van het binaire bestand van het programma |
variable "contract" {value = svm::get_program_from_native_project("my_program")}output "idl" {value = variable.contract.idl}
sol_to_lamports
svm::sol_to_lamports converteert het opgegeven SOL-bedrag naar lamports.
output "lamports" {value = svm::sol_to_lamports(1.1)}// lamports: 1100000000
lamports_to_sol
svm::lamports_to_sol converteert het opgegeven aantal lamports naar SOL.
output "sol" {value = svm::lamports_to_sol(1100000000)}// sol: 1.1
find_pda
svm::find_pda vindt een geldig PDA aan de hand van het opgegeven programma-id
en seeds.
Invoer
| Naam | Verplicht | Type | Beschrijving |
|---|---|---|---|
program_id | verplicht | string | Het adres van het programma waarvan het PDA is afgeleid |
seeds | optioneel | array[string] | Een optionele reeks seeds (max. 16, elk 32 bytes) |
variable "pda" {value = svm::find_pda("3bv3j4GvMPjvvBX9QdoX27pVoWhDSXpwKZipFF1QiVr6", ["data"])}output "pda" {value = std::encode_base58(variable.pda.pda)}output "bump" {value = variable.pda.bump_seed}// > pda: 4amHoWMBgLkPfM8Nq9ZP33Liq9FCuqrLoU1feejkdsUJ// > bump: 252
get_associated_token_account
svm::get_associated_token_account berekent het adres van de associated token
account voor de opgegeven wallet- en token mint-adressen.
Invoer
| Name | Required | Type | Description |
|---|---|---|---|
wallet_address | required | string | Het adres van de wallet |
token_mint_address | optional | string | Het adres van de token mint |
variable "token_account" {value = svm::get_associated_token_account(signer.caller.address, "So11111111111111111111111111111111111111112")}
create_token_account_instruction
svm::create_token_account_instruction maakt ruwe instructiebytes aan om een
associated token account te maken.
Invoer
| Name | Required | Type | Description |
|---|---|---|---|
funding_address | required | string | Het adres van het financieringsaccount |
wallet_address | required | string | Het adres van de wallet |
token_mint_address | optional | string | Het adres van de token mint |
token_program_id | optional | string | Het adres van het token program |
action "call" "svm::process_instructions" {signers = [signer.caller]instruction {raw_bytes = svm::create_token_account_instruction(signer.caller.address, // funding addresssigner.caller.address, // wallet addressvariable.token_mint, // token mint addressvariable.token_program // token program id)}}
u64
svm::u64 maakt een byte-arrayrepresentatie van een u64-geheel getal, geschikt
voor gebruik als seed in PDA-afleiding.
Invoer
| Name | Required | Type | Description |
|---|---|---|---|
value | required | integer | Het u64-geheel getal om te converteren naar een byte-array |
variable "pda" {value = svm::find_pda("3bv3j4GvMPjvvBX9QdoX27pVoWhDSXpwKZipFF1QiVr6", [svm::u64(1000000000)])}
i64
svm::i64 maakt een byte-arrayrepresentatie van een i64-geheel getal, geschikt
voor gebruik als seed in PDA-afleiding.
Invoer
| Name | Required | Type | Description |
|---|---|---|---|
value | required | integer | Het i64-geheel getal om te converteren naar een byte-array |
variable "pda" {value = svm::find_pda("3bv3j4GvMPjvvBX9QdoX27pVoWhDSXpwKZipFF1QiVr6", [svm::i64(-1000000000)])}
Is this page helpful?