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

# Transacties

> Voer transacties uit en simuleer ze met LiteSVM in TypeScript

Methoden voor het verzenden, simuleren en beheren van transacties.

## sendTransaction

```typescript
sendTransaction(tx: Transaction): TransactionMetadata | FailedTransactionMetadata
```

Voer een transactie uit. Geeft bij succes `TransactionMetadata` terug, of
`FailedTransactionMetadata` bij een fout. Controleer welke je hebt gekregen met
`instanceof FailedTransactionMetadata`. Een mislukt resultaat heeft `err()` voor de
fout en `meta()` voor de bijbehorende metadata, inclusief de logs.

```typescript
import { FailedTransactionMetadata } from "litesvm";

const result = client.svm.sendTransaction(signedTx);

if (result instanceof FailedTransactionMetadata) {
  // Check for errors
  console.error("Transaction failed:", result.err());
  console.error("Logs:", result.meta().logs());
} else {
  // Access result properties (note: these are getter functions)
  console.log("Signature:", result.signature());
  console.log("Compute units:", result.computeUnitsConsumed());
  console.log("Logs:", result.logs());
}
```

<Info>
  `FailedTransactionMetadata` komt uit het `litesvm`-pakket, dat
  door `@solana/kit-plugin-litesvm` wordt geïnstalleerd. Voeg het met
  `npm install litesvm` toe aan je eigen dependencies, zodat je het kunt importeren.
</Info>

<Warning>
  Eigenschappen van transactieresultaten zoals `err()`, `computeUnitsConsumed()`,
  `logs()` en `signature()` zijn **getterfuncties**, geen eigenschappen. Roep ze altijd
  aan met haakjes.
</Warning>

### Methoden van TransactionMetadata

| Methode                   | Retourneert                 | Beschrijving                 |
| ------------------------ | ----------------------- | --------------------------- |
| `signature()`            | `Uint8Array`            | Bytes van de transactiehandtekening |
| `computeUnitsConsumed()` | `bigint`                | Gebruikte compute units          |
| `logs()`                 | `string[]`              | Programmalogs                |
| `innerInstructions()`    | `InnerInstruction[]`    | Interne (CPI-)instructies    |
| `returnData()`           | `TransactionReturnData` | Retourdata van programma's   |
| `prettyLogs()`           | `string`                | Opgemaakte logs met kleuren  |

## simulateTransaction

```typescript
simulateTransaction(tx: Transaction): SimulatedTransactionInfo | FailedTransactionMetadata
```

Simuleer een transactie zonder de state te wijzigen.

```typescript
import { FailedTransactionMetadata } from "litesvm";

const simResult = client.svm.simulateTransaction(signedTx);

if (simResult instanceof FailedTransactionMetadata) {
  console.error("Simulation failed:", simResult.err());
  console.error("Logs:", simResult.meta().logs());
} else {
  // Use .meta() to get TransactionMetadata
  const meta = simResult.meta();
  console.log("Would use", meta.computeUnitsConsumed(), "compute units");
  console.log("Logs:", meta.logs());

  // Get post-execution account states
  const postAccounts = simResult.postAccounts();
  console.log("Post-state accounts:", postAccounts);
}
```

<Info>
  Simulatie wijzigt de state niet. Gebruik het om transacties te controleren voordat je ze verzendt.
</Info>

## Blockhash-beheer

### latestBlockhash

```typescript
latestBlockhash(): Blockhash
```

Haal de huidige blockhash op.

```typescript
const blockhash = client.svm.latestBlockhash();
console.log("Blockhash:", blockhash);
```

### getLatestBlockhash (via client.rpc)

Haal de blockhash op met levensduurinformatie om transacties handmatig op te bouwen.
Gebruik de RPC-helper, want die geeft zowel `blockhash` als `lastValidBlockHeight` terug.

```typescript
import {
  createTransactionMessage,
  setTransactionMessageLifetimeUsingBlockhash
} from "@solana/kit";

const { value: blockhashLifetime } = await client.rpc
  .getLatestBlockhash()
  .send();

const tx = setTransactionMessageLifetimeUsingBlockhash(
  blockhashLifetime,
  createTransactionMessage({ version: 0 })
);
```

<Info>
  Als je programmaplug-ins zoals `systemProgram()` of `tokenProgram()` gebruikt, hoef je de blockhash nooit zelf op te halen — `client.sendTransaction()` (en
  de `.sendTransaction()`-helper op instructieketens) regelen dat voor je.
</Info>

### expireBlockhash

```typescript
expireBlockhash(): void
```

Ga naar een nieuwe blockhash. Handig om scenario's te testen waarin een blockhash verloopt.

```typescript
const oldBlockhash = client.svm.latestBlockhash();
client.svm.expireBlockhash();
const newBlockhash = client.svm.latestBlockhash();

console.log("Old:", oldBlockhash);
console.log("New:", newBlockhash);
// Blockhashes will be different
```

## Transactiegeschiedenis

Schakel de transactiegeschiedenis in om transacties na het verzenden op te halen:

```typescript
// Enable history storage (stores last N transactions)
client.svm.withTransactionHistory(100n);

// Send a transaction
const result = client.svm.sendTransaction(signedTx);

// Later, retrieve it by signature (base58 string)
// Note: getTransaction expects a base58-encoded signature string
```
