> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# SVM-functies

> Functies voor Solana en SVM-compatibele blockchains

Deze functies zijn beschikbaar wanneer je de SVM-addon gebruikt voor Solana en
SVM-compatibele blockchains.

## system_program_id

`svm::system_program_id` geeft de id van het system program terug,
`11111111111111111111111111111111`.

```hcl
output "system_program_id" {
    value = svm::system_program_id()
}
// > 11111111111111111111111111111111
```

---

## default_pubkey

`svm::default_pubkey` geeft een standaard publieke sleutel terug,
`11111111111111111111111111111111`.

```hcl
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 voor een
programma-aanroep, met typecontrole en serialisatie op basis van het
opgegeven IDL-bestand.

### Inputs

| Naam               | Vereist | Type          | Beschrijving                                                 |
| ------------------ | -------- | ------------- | ----------------------------------------------------------- |
| `idl_path`         | vereist | string        | Het pad, relatief ten opzichte van txtx.yml, naar het IDL-`.json`-bestand |
| `instruction_name` | vereist | string        | De naam van de instructie waarvoor data moet worden gegenereerd            |
| `arguments`        | optioneel | array[string] | De instructieargumenten waarvoor data moet worden gegenereerd              |

```hcl
output "data" {
    value = svm::get_instruction_data_from_idl_path("idl.json", "my_instruction", ["arg1", "arg2"])
}
// > data: 0xc3f1b80e7f9b443504000000617267310400000061726732
```

Voor een Anchor IDL bestaat de data uit de 8-byte discriminator van de instructie (hier
`c3f1b80e7f9b4435`, de eerste 8 bytes van `sha256("global:my_instruction")`),
gevolgd door de Borsh-gecodeerde argumenten: elke string is een 4-byte little-endian
lengte met de bijbehorende UTF-8-bytes.

---

## get_instruction_data_from_idl

`svm::get_instruction_data_from_idl` maakt gecodeerde instruction data voor een
programma-aanroep, met typecontrole en serialisatie op basis van de
opgegeven IDL-data.

### Inputs

| Naam               | Vereist | Type              | Beschrijving                                                             |
| ------------------ | -------- | ----------------- | ----------------------------------------------------------------------- |
| `idl`              | vereist | string \| SVM_IDL | De IDL van het programma                                                         |
| `instruction_name` | vereist | string            | De naam van de instructie waarvoor data moet worden gegenereerd, zoals geïndexeerd in de IDL |
| `arguments`        | optioneel | array[string]     | De instructieargumenten waarvoor data moet worden gegenereerd                          |

```hcl
output "data" {
    value = svm::get_instruction_data_from_idl(variable.contract.idl, "my_instruction", ["arg1", "arg2"])
}
// > data: 0xc3f1b80e7f9b443504000000617267310400000061726732
```

---

## get_program_from_anchor_project

`svm::get_program_from_anchor_project` haalt de deployment-artefacten op voor een
programma in een Anchor-project.

### Inputs

| Naam           | Vereist | Type   | Beschrijving                              |
| -------------- | -------- | ------ | ---------------------------------------- |
| `program_name` | vereist | string | De naam van het programma dat wordt gedeployed   |
| `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  |

```hcl
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 deployment-artefacten op voor een
programma dat geen Anchor-programma is.

### Inputs

| Naam           | Vereist | Type   | Beschrijving                              |
| -------------- | -------- | ------ | ---------------------------------------- |
| `program_name` | vereist | string | De naam van het programma dat wordt gedeployed   |
| `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  |

```hcl
variable "contract" {
    value = svm::get_program_from_native_project("my_program")
}
output "idl" {
    value = variable.contract.idl
}
```

---

## sol_to_lamports

`svm::sol_to_lamports` zet het opgegeven bedrag in SOL om naar lamports.

```hcl
output "lamports" {
    value = svm::sol_to_lamports(1.1)
}
// lamports: 1100000000
```

---

## lamports_to_sol

`svm::lamports_to_sol` zet het opgegeven aantal lamports om naar SOL.

```hcl
output "sol" {
    value = svm::lamports_to_sol(1100000000)
}
// sol: 1.1
```

---

## find_pda

`svm::find_pda` zoekt een geldig PDA met behulp van de opgegeven program-id en seeds.

### Inputs

| Naam         | Vereist | Type          | Beschrijving                                        |
| ------------ | -------- | ------------- | -------------------------------------------------- |
| `program_id` | vereist | string        | Het adres van het programma waarvan de PDA is afgeleid |
| `seeds`      | optioneel | array[string] | Een optionele array van seeds (max. 16, elk 32 bytes) |

```hcl
variable "pda" {
    value = svm::find_pda("3bv3j4GvMPjvvBX9QdoX27pVoWhDSXpwKZipFF1QiVr6", ["data"])
}
output "pda" {
    value = variable.pda.pda
}
output "bump" {
    value = variable.pda.bump_seed
}
// > pda: AAU8CSawL7uBQLt4QHdTtwsNuRQthNtYzhMVNx2bwuGC
// > bump: 254
```

---

## 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.

### Inputs

| Naam                 | Vereist | Type   | Beschrijving                   |
| -------------------- | -------- | ------ | ----------------------------- |
| `wallet_address`     | vereist | string | Het adres van de wallet     |
| `token_mint_address` | optioneel | string | Het adres van de token mint |

```hcl
variable "token_account" {
    value = svm::get_associated_token_account(signer.caller.address, "So11111111111111111111111111111111111111112")
}
```

---

## create_token_account_instruction

`svm::create_token_account_instruction` maakt ruwe instructie-bytes aan om
een associated token account aan te maken.

### Inputs

| Naam                 | Vereist | Type   | Beschrijving                        |
| -------------------- | -------- | ------ | ---------------------------------- |
| `funding_address`    | vereist | string | Het adres van het financieringsaccount |
| `wallet_address`     | vereist | string | Het adres van de wallet          |
| `token_mint_address` | optioneel | string | Het adres van de token mint      |
| `token_program_id`   | optioneel | string | Het adres van het token program   |

```hcl
action "call" "svm::process_instructions" {
    signers = [signer.caller]

    instruction {
        raw_bytes = svm::create_token_account_instruction(
            signer.caller.address, // funding address
            signer.caller.address, // wallet address
            variable.token_mint, // token mint address
            variable.token_program // token program id
        )
    }
}
```

---

## u64

`svm::u64` maakt een bytearray-representatie van een u64-integer, geschikt voor
gebruik als seed bij PDA-afleiding.

### Inputs

| Naam    | Vereist | Type    | Beschrijving                                |
| ------- | -------- | ------- | ------------------------------------------ |
| `value` | vereist | integer | De u64-integer die moet worden omgezet naar een bytearray |

```hcl
variable "pda" {
    value = svm::find_pda("3bv3j4GvMPjvvBX9QdoX27pVoWhDSXpwKZipFF1QiVr6", [svm::u64(1000000000)])
}
```

---

## i64

`svm::i64` maakt een bytearray-representatie van een i64-integer, geschikt voor
gebruik als seed bij PDA-afleiding.

### Inputs

| Naam    | Vereist | Type    | Beschrijving                                |
| ------- | -------- | ------- | ------------------------------------------ |
| `value` | vereist | integer | De i64-integer die moet worden omgezet naar een bytearray |

```hcl
variable "pda" {
    value = svm::find_pda("3bv3j4GvMPjvvBX9QdoX27pVoWhDSXpwKZipFF1QiVr6", [svm::i64(-1000000000)])
}
```
