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

# Versioned Transactions

> Legacy, v0, and v1 transaction formats on Solana, including Address Lookup Tables (ALTs), version detection, the v1 transaction config, and resource limits.

<Info>
  **Summary**

  Solana has three transaction formats: legacy, v0, and v1. **v0** adds Address
  Lookup Tables (ALTs) for referencing accounts via 1-byte indices. **v1**
  raises the size limit to 4,096 bytes, moves resource limits into the message
  itself, and removes ALTs.
</Info>

Solana supports three transaction formats: **legacy**, **v0**, and **v1**. Each
one is described below with the same three parts: how it lays out its bytes on
the wire, how it references accounts, and where its resource limits come from.

<Warning>
  **v1 activation status**

  The [v1 format](https://solana.com/upgrades/larger-transaction-sizes) is
  active on mainnet, devnet, and testnet. Reading transactions is a breaking
  change: clients that do not opt in fail on v1 transactions. Existing apps
  should review [preparing for v1](#preparing-for-v1).
</Warning>

## Format comparison

| Limit                 | legacy                     | v0                         | v1                                                                                 |
| --------------------- | -------------------------- | -------------------------- | ---------------------------------------------------------------------------------- |
| Max transaction size  | 1,232 bytes                | 1,232 bytes                | **4,096 bytes**                                                                    |
| Account addresses     | ~32, size-bound            | 64, via lookup tables      | **64, inline** (96 with [SIMD-0596](https://solana.com/upgrades/v1-account-limit)) |
| Address lookup tables | not supported              | supported                  | **not supported**                                                                  |
| Resource limits       | ComputeBudget instructions | ComputeBudget instructions | **message config**                                                                 |

Jump to: [Legacy](#legacy-format) · [v0](#v0-format) · [v1](#v1-format)

## Legacy format

The original format, and still the default in most tooling. It has no version
prefix at all: the first byte of the transaction is the compact-u16 count of the
signature array, and the first byte of the message is `num_required_signatures`,
whose high bit is always unset.

### Legacy wire layout

| Field              | Size                          | Description                                      |
| ------------------ | ----------------------------- | ------------------------------------------------ |
| `num_signatures`   | compact-u16                   | Number of signatures                             |
| `signatures`       | `num_signatures` x 64 bytes   | Ed25519 signatures                               |
| `header`           | 3 bytes                       | MessageHeader — first byte has version bit unset |
| `num_account_keys` | compact-u16                   | Number of account keys                           |
| `account_keys`     | `num_account_keys` x 32 bytes | Public keys, all inline                          |
| `recent_blockhash` | 32 bytes                      | Lifetime specifier                               |
| `num_instructions` | compact-u16                   | Number of instructions                           |
| `instructions`     | variable                      | Each instruction serialized contiguously         |

Every variable-length array is prefixed with a compact-u16 length: 1 byte for
values 0–127, 2–3 bytes for larger values. For the per-instruction layout and a
worked size calculation, see
[transaction binary format](/developers/docs/core/transactions/transaction-structure#transaction-binary-format).

### Accounts in legacy

Every account is written out as a full 32-byte public key in `account_keys`, and
instructions reference them by 1-byte index into that array. There is no way to
reference an account that is not spelled out in the transaction, which is what
bounds a legacy transaction to roughly 32 accounts before it runs out of its
1,232 bytes.

### Resource limits in legacy

Compute unit limit, loaded accounts data size limit, heap size, and priority fee
are all requested by including
[ComputeBudget program instructions](/developers/docs/core/fees/compute-budget) in the
transaction. Each one costs an instruction slot and 150 compute units. Omitting
them is safe: the runtime falls back to defaults of 200,000 CU per instruction
(capped at 1.4M), a 64 MiB data size limit, a 32 KiB heap, and a priority fee of
zero.

## V0 format

v0 is a legacy message plus two things: a `0x80` version prefix byte and an
`address_table_lookups` array appended after the instructions. Everything before
those is byte-identical to legacy.

### V0 wire layout

| Field                   | Size                          | Description                                     |
| ----------------------- | ----------------------------- | ----------------------------------------------- |
| `num_signatures`        | compact-u16                   | Number of signatures                            |
| `signatures`            | `num_signatures` x 64 bytes   | Ed25519 signatures                              |
| `0x80`                  | 1 byte                        | Version prefix byte — first byte of the message |
| `header`                | 3 bytes                       | MessageHeader (same as legacy)                  |
| `num_account_keys`      | compact-u16                   | Number of static account keys                   |
| `static_account_keys`   | `num_account_keys` x 32 bytes | Keys that appear literally in the transaction   |
| `recent_blockhash`      | 32 bytes                      | Lifetime specifier                              |
| `num_instructions`      | compact-u16                   | Number of instructions                          |
| `instructions`          | variable                      | Same format as legacy                           |
| `address_table_lookups` | compact-u16 + variable        | ALT references (see below)                      |

Each address table lookup entry contains:

| Field              | Size                     | Description                                 |
| ------------------ | ------------------------ | ------------------------------------------- |
| `account_key`      | 32 bytes                 | The ALT account's public key                |
| `writable_indexes` | compact-u16 + N x 1 byte | Indices into the ALT for writable accounts  |
| `readonly_indexes` | compact-u16 + N x 1 byte | Indices into the ALT for read-only accounts |

### Address lookup tables

An ALT is an onchain account that stores up to 256 public keys. By referencing
an ALT, a transaction can include additional accounts using 1-byte indices
instead of 32-byte public keys, significantly reducing per-account overhead.

At runtime, before execution begins, the validator resolves all ALT references
into full public keys. The resolved addresses are appended to the static account
keys to form the complete account keys list. ALT-resolved accounts follow the
same ordering as static accounts: writable lookups come before read-only
lookups.

<Note>
  Address lookup tables only affect how accounts are referenced in the on-wire
  transaction. At execution time, the runtime resolves all indices to full
  account addresses. ALT-resolved accounts can only be writable or read-only
  (non-signer); they cannot be signers.
</Note>

### Create and use an address lookup table

This example creates a lookup table, adds an address, and uses the table to
compile and send a v0 transaction.

<Warning>
  **`@solana/web3.js` 1.x is no longer actively maintained**

  It receives critical fixes only. Use [Kit](/developers/docs/clients/official/javascript#solana-kit) for new code. To migrate existing code, follow the [Kit upgrade guide](https://www.solanakit.com/docs/upgrade-guide), or the [web3.js v3 migration guide](https://github.com/solana-foundation/solana-web3.js/blob/main/docs/web3js-v1-to-v3-migration.md) to keep the class-based API.

  To run this code, install 1.x with `npm install @solana/web3.js@1`. A plain `npm install @solana/web3.js` installs v3, which this code doesn't run on.
</Warning>

```ts title="Versioned transaction with an ALT"
import {
  AddressLookupTableProgram,
  Connection,
  Keypair,
  LAMPORTS_PER_SOL,
  sendAndConfirmTransaction,
  SystemProgram,
  Transaction,
  TransactionMessage,
  VersionedTransaction,
} from "@solana/web3.js";

const connection = new Connection(
  process.env.SOLANA_RPC_URL ?? "http://localhost:8899",
  "confirmed",
);
const payer = Keypair.generate();
const recipient = Keypair.generate();

const airdropSignature = await connection.requestAirdrop(
  payer.publicKey,
  LAMPORTS_PER_SOL,
);
const { blockhash, lastValidBlockHeight } =
  await connection.getLatestBlockhash();
await connection.confirmTransaction({
  blockhash,
  lastValidBlockHeight,
  signature: airdropSignature,
});

// Create the lookup table. Its address is derived from the authority and slot.
const recentSlot = await connection.getSlot("finalized");
const [createLookupTableInstruction, lookupTableAddress] =
  AddressLookupTableProgram.createLookupTable({
    authority: payer.publicKey,
    payer: payer.publicKey,
    recentSlot,
  });

await sendAndConfirmTransaction(
  connection,
  new Transaction().add(createLookupTableInstruction),
  [payer],
);

// Store addresses that do not need to sign the v0 transaction in the table.
const extendLookupTableInstruction =
  AddressLookupTableProgram.extendLookupTable({
    authority: payer.publicKey,
    payer: payer.publicKey,
    lookupTable: lookupTableAddress,
    addresses: [recipient.publicKey],
  });

await sendAndConfirmTransaction(
  connection,
  new Transaction().add(extendLookupTableInstruction),
  [payer],
);

const lookupTableAccount = (
  await connection.getAddressLookupTable(lookupTableAddress)
).value;
if (!lookupTableAccount) {
  throw new Error("Lookup table was not found");
}

// Addresses added to a table become usable in the slot after they are added.
while (
  (await connection.getSlot("confirmed")) <=
  lookupTableAccount.state.lastExtendedSlot
) {
  await new Promise((resolve) => setTimeout(resolve, 400));
}

const transferInstruction = SystemProgram.transfer({
  fromPubkey: payer.publicKey,
  toPubkey: recipient.publicKey,
  lamports: 1_000_000,
});
const transactionLifetime = await connection.getLatestBlockhash();

// Passing the table to compileToV0Message replaces eligible 32-byte addresses
// with 1-byte lookup indexes in the serialized transaction.
const message = new TransactionMessage({
  payerKey: payer.publicKey,
  recentBlockhash: transactionLifetime.blockhash,
  instructions: [transferInstruction],
}).compileToV0Message([lookupTableAccount]);

const transaction = new VersionedTransaction(message);
transaction.sign([payer]);

const signature = await connection.sendTransaction(transaction);
await connection.confirmTransaction({ ...transactionLifetime, signature });
console.log("Transaction signature:", signature);
```

Only non-signer accounts can be loaded from a lookup table. The fee payer and
every required signer remain in the message's static account list. An address
also cannot be looked up in the same slot in which it was added, so the example
waits for the next confirmed slot before compiling the v0 message.

### Resource limits in v0

Unchanged from legacy: ComputeBudget instructions, with the same defaults when
they are omitted.

## V1 format

v1 raises the size limit to 4,096 bytes and restructures the message around a
**transaction config**: resource limits move out of ComputeBudget instructions
and into fixed-position fields in the message itself. This lets the network rank
a transaction by priority fee with a single fixed-offset read instead of
scanning and deserializing its instruction list.

### V1 wire layout

| Field                  | Size         | Description                                                                        |
| ---------------------- | ------------ | ---------------------------------------------------------------------------------- |
| `0x81`                 | 1 byte       | Version prefix byte — the first byte of the transaction                            |
| `header`               | 3 bytes      | MessageHeader (same as legacy)                                                     |
| `config_mask`          | 4 bytes      | `u32` LE bitmask marking which config values are present                           |
| `recent_blockhash`     | 32 bytes     | Lifetime specifier                                                                 |
| `num_instructions`     | 1 byte       | Fixed-width count, max 64                                                          |
| `num_addresses`        | 1 byte       | Fixed-width count, max 64 (96 with SIMD-0596)                                      |
| `addresses`            | N x 32 bytes | Account addresses, all inline — no lookup table references                         |
| `config_values`        | 0–20 bytes   | One value per set mask bit, in bit order (see below)                               |
| `instruction_headers`  | N x 4 bytes  | Per instruction: `program_id_index` (u8), `num_accounts` (u8), `data_len` (u16 LE) |
| `instruction_payloads` | variable     | Per instruction: account indices, then instruction data                            |
| `signatures`           | N x 64 bytes | At the tail, with no length prefix — the count comes from the header               |

Two structural differences from legacy and v0 are worth noting when writing a
decoder. The counts are fixed-width `u8` fields rather than compact-u16, and the
instructions are split into two runs: every fixed-size header first, then every
variable-length payload, instead of each instruction being contiguous.

### Accounts in v1: no address lookup tables

v1 removes ALT support deliberately. 64 raw addresses is 2,048 bytes, and the 96
addresses allowed after
[SIMD-0596](https://solana.com/upgrades/v1-account-limit) are 3,072 bytes, both
comfortably inside the 4,096-byte limit, so every address is inline as it is in
legacy. If your application depends on lookup tables, moving to v1 means
inlining those addresses.

### Resource limits in v1: the transaction config

The config is a `u32` bitmask followed by fixed-width values for each field
whose bit is set:

| Bit(s) | Field                           | Width | Notes                                       |
| ------ | ------------------------------- | ----- | ------------------------------------------- |
| 0–1    | Priority fee                    | u64   | **Total lamports** — both bits set together |
| 2      | Compute unit limit              | u32   |                                             |
| 3      | Loaded accounts data size limit | u32   |                                             |
| 4      | Requested heap size             | u32   |                                             |

Unknown bits are rejected. Because the message is signed, unrecognized config
fields cannot be silently dropped.

<Warning>
  **Priority fee is total lamports, not a price**

  In legacy and v0, the priority fee is set via `SetComputeUnitPrice` as
  **micro-lamports per compute unit**, multiplied by the compute unit limit. In
  v1 it is an **absolute total in lamports** — no multiplication, no rounding.
  Do not carry the per-CU arithmetic across. The total fee formula is otherwise
  unchanged: `(signatures × lamports_per_signature) + priority_fee`.
</Warning>

#### ComputeBudget instructions are no-ops in v1

A v1 transaction does not reject ComputeBudget instructions — it **ignores**
them for configuration. They still execute as successful no-ops, consuming 150
compute units and one of the 64 instruction slots while having no effect on the
budget. Strip them when building v1 transactions, and stop scanning for them
when reading v1 transactions: the values live in the message config.

#### Config fields must be set explicitly

The most important behavioral change for senders: unlike legacy and v0, v1
transactions must set the compute unit limit and loaded accounts data size limit
explicitly or your transaction will fail.

| Unset field               | legacy / v0                    | v1          | Symptom if omitted                                              |
| ------------------------- | ------------------------------ | ----------- | --------------------------------------------------------------- |
| Compute unit limit        | 200k per instruction, max 1.4M | **0 CU**    | Fails immediately, out of budget                                |
| Loaded accounts data size | 64 MiB                         | **0 bytes** | `MaxLoadedAccountsDataSizeExceeded` on the first account loaded |
| Priority fee              | 0                              | 0           | —                                                               |
| Heap size                 | 32 KiB                         | 32 KiB      | —                                                               |

The recommended approach is to simulate once with both limits maxed, then write
the returned `unitsConsumed` and `loadedAccountsDataSize` back into the config,
rounding the data size up to the next 32 KiB page for headroom (the block cost
model charges in 32 KiB pages, so headroom below the next page boundary is
free).

### Building a v1 transaction

A v1 message is assembled through the same pipeline as a legacy or v0 one. The
difference is `setTransactionMessageConfig`: the resource limits are a property
of the message, so the instruction list holds only the program instructions.

<Tabs>
<Tab title="Kit">
<div className="sol-tab-label">Kit</div>

```ts
import {
  appendTransactionMessageInstruction,
  assertIsTransactionWithBlockhashLifetime,
  createClient,
  createTransactionMessage,
  generateKeyPairSigner,
  getSignatureFromTransaction,
  lamports,
  pipe,
  sendAndConfirmTransactionFactory,
  setTransactionMessageConfig,
  setTransactionMessageFeePayerSigner,
  setTransactionMessageLifetimeUsingBlockhash,
  signTransactionMessageWithSigners,
} from "@solana/kit";
import { rpcAirdrop, solanaRpc } from "@solana/kit-plugin-rpc";
import { airdropPayer, payer } from "@solana/kit-plugin-signer";
import { getTransferSolInstruction } from "@solana-program/system";

const sender = await generateKeyPairSigner();
const recipient = await generateKeyPairSigner();

const client = await createClient()
  .use(payer(sender))
  .use(
    solanaRpc({
      rpcUrl: "http://localhost:8899",
      rpcSubscriptionsUrl: "ws://localhost:8900",
    }),
  )
  .use(rpcAirdrop())
  .use(airdropPayer(lamports(1_000_000_000n)));

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

// A v1 message is assembled through the same pipeline as a legacy or v0 one.
// The difference is the config: a v1 transaction carries its resource limits in
// the message itself, so no ComputeBudget instructions are compiled in.
const transactionMessage = pipe(
  createTransactionMessage({ version: 1 }),
  (m) => setTransactionMessageFeePayerSigner(sender, m),
  (m) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, m),
  (m) =>
    appendTransactionMessageInstruction(
      getTransferSolInstruction({
        source: sender,
        destination: recipient.address,
        amount: lamports(10_000_000n),
      }),
      m,
    ),
  // The compute unit limit and loaded accounts data size limit both default to
  // zero on v1, so a transaction that leaves them unset always fails. The
  // priority fee is an absolute total in lamports, not a price per compute
  // unit.
  (m) =>
    setTransactionMessageConfig(
      {
        computeUnitLimit: 20_000,
        loadedAccountsDataSizeLimit: 64 * 1024,
        priorityFeeLamports: 5_000n,
      },
      m,
    ),
);

const signedTransaction =
  await signTransactionMessageWithSigners(transactionMessage);
assertIsTransactionWithBlockhashLifetime(signedTransaction);

await sendAndConfirmTransactionFactory({
  rpc: client.rpc,
  rpcSubscriptions: client.rpcSubscriptions,
})(signedTransaction, { commitment: "confirmed" });

const transactionSignature = getSignatureFromTransaction(signedTransaction);
console.log("Transaction Signature:", transactionSignature);
```

<div className="sol-run" data-run="cookbook/transactions/v1-transactions/build" data-tab="Kit">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Transaction Signature: ZXbwX8LzjRbEG4msdSaAuHAM5MNBxtz5rCcmNi14mBeh11QRWAXDx2uiciE2HVQFWRgSEzAcMt1DNsZ7CiVcumg
```

</div>
</div>

</Tab>
<Tab title="Go">
<div className="sol-tab-label">Go</div>

```go
package main

import (
	"context"
	"fmt"
	"time"

	"github.com/solana-foundation/solana-go/v2"
	"github.com/solana-foundation/solana-go/v2/programs/system"
	"github.com/solana-foundation/solana-go/v2/rpc"
)

func main() {
	ctx := context.Background()
	client := rpc.New("http://localhost:8899")

	sender := solana.NewWallet()
	recipient := solana.NewWallet()

	_, err := client.RequestAirdrop(ctx, sender.PublicKey(), solana.LAMPORTS_PER_SOL, rpc.CommitmentConfirmed)
	if err != nil {
		panic(err)
	}
	time.Sleep(2 * time.Second)

	recent, err := client.GetLatestBlockhash(ctx, rpc.CommitmentConfirmed)
	if err != nil {
		panic(err)
	}

	// A v1 transaction carries its resource limits in the message itself, so
	// there are no ComputeBudget instructions. Both limits default to zero, so
	// set them. The priority fee is a total in lamports, not a price per unit.
	tx, err := solana.NewTransaction(
		[]solana.Instruction{
			system.NewTransferInstruction(10_000_000, sender.PublicKey(), recipient.PublicKey()).Build(),
		},
		recent.Value.Blockhash,
		solana.TransactionPayer(sender.PublicKey()),
		solana.TransactionV1Config(solana.TransactionConfig{}.
			WithComputeUnitLimit(20_000).
			WithLoadedAccountsDataSizeLimit(64*1024).
			WithPriorityFee(5_000)),
	)
	if err != nil {
		panic(err)
	}
	tx.Sign(func(solana.PublicKey) *solana.PrivateKey { return &sender.PrivateKey })

	sig, err := client.SendTransactionWithOpts(ctx, tx, rpc.TransactionOpts{
		PreflightCommitment: rpc.CommitmentConfirmed,
	})
	if err != nil {
		panic(err)
	}
	fmt.Println("Transaction Signature:", sig)
}
```

<div className="sol-run" data-run="cookbook/transactions/v1-transactions/build" data-tab="Go">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Transaction Signature: DYarmikpyJPrMVwEZ7sUu3JG4pjfzqavdnejj4kHykz8LYqNL69WihfqUpRMJjA6XU7Nn6okF2NYzBeJdacVP1z
```

</div>
</div>

</Tab>
</Tabs>

Kit also exposes a setter per config field —
`setTransactionMessagePriorityFeeLamports`,
`setTransactionMessageComputeUnitLimit`,
`setTransactionMessageLoadedAccountsDataSizeLimit`, and
`setTransactionMessageHeapSize` — for setting them one at a time.

### Sizing the limits by simulation

Rather than guessing the two mandatory limits, measure them. Simulation runs
with both limits raised to the runtime maximum, so it cannot fail for want of
the resources it is measuring. The returned figure is the exact cost of one
simulated run, so add a margin before relying on it.

<Tabs>
<Tab title="Kit">
<div className="sol-tab-label">Kit</div>

```ts
import {
  appendTransactionMessageInstruction,
  assertIsTransactionWithBlockhashLifetime,
  createClient,
  createTransactionMessage,
  estimateAndSetResourceLimitsFactory,
  estimateResourceLimitsFactory,
  fillTransactionMessageProvisoryResourceLimits,
  generateKeyPairSigner,
  getSignatureFromTransaction,
  lamports,
  pipe,
  sendAndConfirmTransactionFactory,
  setTransactionMessageFeePayerSigner,
  setTransactionMessageLifetimeUsingBlockhash,
  setTransactionMessagePriorityFeeLamports,
  signTransactionMessageWithSigners,
} from "@solana/kit";
import { rpcAirdrop, solanaRpc } from "@solana/kit-plugin-rpc";
import { airdropPayer, payer } from "@solana/kit-plugin-signer";
import { getTransferSolInstruction } from "@solana-program/system";

const sender = await generateKeyPairSigner();
const recipient = await generateKeyPairSigner();

const client = await createClient()
  .use(payer(sender))
  .use(
    solanaRpc({
      rpcUrl: "http://localhost:8899",
      rpcSubscriptionsUrl: "ws://localhost:8900",
    }),
  )
  .use(rpcAirdrop())
  .use(airdropPayer(lamports(1_000_000_000n)));

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

// The priority fee is a pricing decision that simulation cannot measure, so it
// is set directly. The two resource limits are measured below instead of
// guessed. The provisory fill writes placeholder limits so the message
// simulates at the same size it will be sent at.
const draftMessage = pipe(
  createTransactionMessage({ version: 1 }),
  (m) => setTransactionMessageFeePayerSigner(sender, m),
  (m) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, m),
  (m) =>
    appendTransactionMessageInstruction(
      getTransferSolInstruction({
        source: sender,
        destination: recipient.address,
        amount: lamports(10_000_000n),
      }),
      m,
    ),
  (m) => setTransactionMessagePriorityFeeLamports(5_000n, m),
  fillTransactionMessageProvisoryResourceLimits,
);

// Simulation runs with both limits raised to the runtime maximum, so it cannot
// fail for want of the resources it is measuring.
const estimateAndSetResourceLimits = estimateAndSetResourceLimitsFactory(
  estimateResourceLimitsFactory({ rpc: client.rpc }),
);
const transactionMessage = await estimateAndSetResourceLimits(draftMessage, {
  commitment: "confirmed",
});

// Both are measured: compute units used, and bytes of account data loaded (a
// SOL transfer only loads the System Program, whose data is its 14-byte name).
console.log("Compute unit limit:", transactionMessage.config?.computeUnitLimit);
console.log(
  "Loaded accounts data size limit (bytes):",
  transactionMessage.config?.loadedAccountsDataSizeLimit,
);

const signedTransaction =
  await signTransactionMessageWithSigners(transactionMessage);
assertIsTransactionWithBlockhashLifetime(signedTransaction);

await sendAndConfirmTransactionFactory({
  rpc: client.rpc,
  rpcSubscriptions: client.rpcSubscriptions,
})(signedTransaction, { commitment: "confirmed" });

// The estimate is the exact cost of one simulated run, with nothing to spare.
// Add a margin before relying on it in production.
console.log(
  "Transaction Signature:",
  getSignatureFromTransaction(signedTransaction),
);
```

<div className="sol-run" data-run="cookbook/transactions/v1-transactions/estimate" data-tab="Kit">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Compute unit limit: 150
Loaded accounts data size limit (bytes): 14
Transaction Signature: 23M8HQsjE1Kaj7hGbXsNQ1i9Wif6zwh2iWatJSpuXi8GtrxcuWswpXZsMtJ7n2anPoUn4hMqALhrwrzXmUSkiRAh
```

</div>
</div>

</Tab>
<Tab title="Go">
<div className="sol-tab-label">Go</div>

```go
package main

import (
	"context"
	"fmt"
	"time"

	"github.com/solana-foundation/solana-go/v2"
	"github.com/solana-foundation/solana-go/v2/programs/system"
	"github.com/solana-foundation/solana-go/v2/rpc"
)

func main() {
	ctx := context.Background()
	client := rpc.New("http://localhost:8899")

	sender := solana.NewWallet()
	recipient := solana.NewWallet()

	_, err := client.RequestAirdrop(ctx, sender.PublicKey(), solana.LAMPORTS_PER_SOL, rpc.CommitmentConfirmed)
	if err != nil {
		panic(err)
	}
	time.Sleep(2 * time.Second)

	recent, err := client.GetLatestBlockhash(ctx, rpc.CommitmentConfirmed)
	if err != nil {
		panic(err)
	}
	transfer := system.NewTransferInstruction(10_000_000, sender.PublicKey(), recipient.PublicKey()).Build()
	buildTx := func(config solana.TransactionConfig) *solana.Transaction {
		tx, err := solana.NewTransaction(
			[]solana.Instruction{transfer},
			recent.Value.Blockhash,
			solana.TransactionPayer(sender.PublicKey()),
			solana.TransactionV1Config(config.WithPriorityFee(5_000)),
		)
		if err != nil {
			panic(err)
		}
		tx.Sign(func(solana.PublicKey) *solana.PrivateKey { return &sender.PrivateKey })
		return tx
	}

	// Simulate with both limits at the runtime maximum, then read what the
	// transaction actually used.
	sim, err := client.SimulateTransactionWithOpts(ctx, buildTx(solana.TransactionConfig{}.
		WithComputeUnitLimit(1_400_000).
		WithLoadedAccountsDataSizeLimit(64*1024*1024),
	), &rpc.SimulateTransactionOpts{Commitment: rpc.CommitmentConfirmed})
	if err != nil {
		panic(err)
	}
	computeUnits := uint32(*sim.Value.UnitsConsumed)
	dataSize := *sim.Value.LoadedAccountsDataSize
	fmt.Println("Compute unit limit:", computeUnits)
	fmt.Println("Loaded accounts data size limit:", dataSize)

	// The estimate is the exact cost of one run; add a margin in production.
	tx := buildTx(solana.TransactionConfig{}.
		WithComputeUnitLimit(computeUnits).
		WithLoadedAccountsDataSizeLimit(dataSize))
	sig, err := client.SendTransactionWithOpts(ctx, tx, rpc.TransactionOpts{
		PreflightCommitment: rpc.CommitmentConfirmed,
	})
	if err != nil {
		panic(err)
	}
	fmt.Println("Transaction Signature:", sig)
}
```

<div className="sol-run" data-run="cookbook/transactions/v1-transactions/estimate" data-tab="Go">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Compute unit limit: 150
Loaded accounts data size limit: 149
Transaction Signature: 3VDdt7FnqmMDNVshHUikdHFJuooLVpCx8qtpobrth8V6hAfjCkXPrauXAiGASKF68BTX5b67EUUXKCmBwDLr8eSW
```

</div>
</div>

</Tab>
</Tabs>

## Preparing for v1

v1 changes **reading** transactions, not just sending them. Any client that
calls `getTransaction` or `getBlock` without opting in fails on v1 transactions:

- Pass `maxSupportedTransactionVersion: 1` — the JSON **integer** `1`, not the
  string `"1"` — to [`getTransaction`](/developers/docs/rpc/http/gettransaction) and
  [`getBlock`](/developers/docs/rpc/http/getblock). Passing `0` fails on v1 transactions
  exactly like omitting the parameter, so a codebase updated during the v0
  rollout still needs the value changed.
- `getTransaction` fails on a v1 transaction with error `-32015`, and one v1
  transaction fails an **entire** `getBlock` response with the same error —
  there is no partial result.
- [`blockSubscribe`](/developers/docs/rpc/websocket/blocksubscribe) emits `block: null` and
  stops advancing, so a consumer that reads that as an empty block silently
  falls behind from the first v1 slot onward.
- `getSignaturesForAddress` never inspects transaction bodies, so v1 signatures
  list normally.
- Opted-in responses include a `transactionConfig` object in the message for v1
  transactions (absent entirely for legacy and v0). Pipelines that derive
  priority fees or compute limits by scanning for ComputeBudget instructions
  silently report **zero** for every v1 transaction.
- Use `encoding: 'base64'` when you decode transactions client-side, and for
  `sendTransaction`/`simulateTransaction` with transactions over 1,232 bytes —
  base58 encoding remains capped at the old size.
- Client library support requires recent versions: `@solana/kit` 8.0+, Agave
  4.2.x-generation Rust crates, or web3.js v3. web3.js v1 reads v1 from 1.99.0
  onward, but cannot build or send it.

### Reading a v1 transaction

Opting in takes the JSON integer `1`. Decoding the returned bytes gives the
version and the config, which is where the resource limits live — scanning the
instruction list for ComputeBudget instructions finds nothing.

<Tabs>
<Tab title="Kit">
<div className="sol-tab-label">Kit</div>

```ts
import {
  decompileTransactionMessage,
  getBase64Encoder,
  getCompiledTransactionMessageDecoder,
  getTransactionDecoder,
} from "@solana/kit";

// Reading a v1 transaction requires opting in. The integer 1 is mandatory:
// omitting the parameter, or passing 0, fails on a v1 transaction rather than
// returning it in a degraded form.
const fetched = await client.rpc
  .getTransaction(transactionSignature, {
    commitment: "confirmed",
    encoding: "base64",
    maxSupportedTransactionVersion: 1,
  })
  .send();
if (fetched === null) {
  throw new Error("the transaction just sent was not found");
}

// The compiled message stores the config as a bitmask plus a positional list,
// so it is decompiled to address the fields by name. Decompiling fetches no
// accounts, because v1 does not support address lookup tables.
const wireTransaction = getBase64Encoder().encode(fetched.transaction[0]);
const transaction = getTransactionDecoder().decode(wireTransaction);
const compiledMessage = getCompiledTransactionMessageDecoder().decode(
  transaction.messageBytes,
);
const message = decompileTransactionMessage(compiledMessage);

console.log("Version:", message.version);
if ("config" in message) {
  // Scanning the instruction list for ComputeBudget instructions finds nothing
  // here — on v1 the limits live in the config.
  console.log("Compute unit limit:", message.config?.computeUnitLimit);
  console.log("Priority fee (lamports):", message.config?.priorityFeeLamports);
}
```

<div className="sol-run" data-run="cookbook/transactions/v1-transactions/read" data-tab="Kit">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Version: 1
Compute unit limit: 20000
Priority fee (lamports): 5000n
```

</div>
</div>

</Tab>
<Tab title="Go">
<div className="sol-tab-label">Go</div>

```go
// Reading a v1 transaction requires opting in with version 1.
maxVersion := rpc.MaxSupportedTransactionVersion1
fetched, err := client.GetTransaction(ctx, sig, &rpc.GetTransactionOpts{
	Commitment:                     rpc.CommitmentConfirmed,
	Encoding:                       solana.EncodingBase64,
	MaxSupportedTransactionVersion: &maxVersion,
})
if err != nil {
	panic(err)
}
read, err := fetched.Transaction.GetTransaction()
if err != nil {
	panic(err)
}

// On v1 the limits live in the message config, not in instructions.
config := read.Message.TransactionConfig
fmt.Println("Is v1:", read.Message.GetVersion() == solana.MessageVersionV1)
fmt.Println("Compute unit limit:", *config.ComputeUnitLimit)
fmt.Println("Priority fee (lamports):", *config.PriorityFee)
```

<div className="sol-run" data-run="cookbook/transactions/v1-transactions/read" data-tab="Go">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Is v1: true
Compute unit limit: 20000
Priority fee (lamports): 5000
```

</div>
</div>

</Tab>
</Tabs>

For the full migration guide — including client library support, streaming
(Geyser/gRPC) version detection, and simulation behavior — see the
[Transaction Format v1 upgrade page](https://solana.com/upgrades/larger-transaction-sizes).
Runnable examples in TypeScript, Rust, Python, and Go live in
[solana-foundation/upgrades-examples](https://github.com/solana-foundation/upgrades-examples/tree/main/transaction-v1).
