Legacy, v0, and v1 transaction formats on Solana, including Address Lookup Tables (ALTs), version detection, the v1 transaction config, and resource limits.
SummarySolana 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.
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.
v1 activation statusThe v1 format 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.
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.
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.
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.
Compute unit limit, loaded accounts data size limit, heap size, and priority fee
are all requested by including
ComputeBudget program instructions 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 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.
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.
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.
This example creates a lookup table, adds an address, and uses the table to
compile and send a v0 transaction.
@solana/web3.js 1.x is no longer actively maintainedIt receives critical fixes only. Use Kit for new code. To migrate existing code, follow the Kit upgrade guide, or the web3.js v3 migration guide 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.
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.
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.
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.
v1 removes ALT support deliberately. 64 raw addresses is 2,048 bytes, and the 96
addresses allowed after
SIMD-0596 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.
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.
Priority fee is total lamports, not a priceIn 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.
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.
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).
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.
Kit
Go
Kit
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);
Kit also exposes a setter per config field —
setTransactionMessagePriorityFeeLamports,
setTransactionMessageComputeUnitLimit,
setTransactionMessageLoadedAccountsDataSizeLimit, and
setTransactionMessageHeapSize — for setting them one at a time.
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.
Kit
Go
Kit
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),);
Output from a local Surfpool network
Output
Compute unit limit: 150Loaded accounts data size limit (bytes): 14Transaction Signature: 23M8HQsjE1Kaj7hGbXsNQ1i9Wif6zwh2iWatJSpuXi8GtrxcuWswpXZsMtJ7n2anPoUn4hMqALhrwrzXmUSkiRAh
Go
package mainimport ( "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)}
Output from a local Surfpool network
Output
Compute unit limit: 150Loaded accounts data size limit: 149Transaction Signature: 3VDdt7FnqmMDNVshHUikdHFJuooLVpCx8qtpobrth8V6hAfjCkXPrauXAiGASKF68BTX5b67EUUXKCmBwDLr8eSW
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 integer1, not the
string "1" — to getTransaction and
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 entiregetBlock response with the same error —
there is no partial result.
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.
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.
Kit
Go
Kit
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);}
Output from a local Surfpool network
Output
Version: 1Compute unit limit: 20000Priority fee (lamports): 5000n
Go
// Reading a v1 transaction requires opting in with version 1.maxVersion := rpc.MaxSupportedTransactionVersion1fetched, 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.TransactionConfigfmt.Println("Is v1:", read.Message.GetVersion() == solana.MessageVersionV1)fmt.Println("Compute unit limit:", *config.ComputeUnitLimit)fmt.Println("Priority fee (lamports):", *config.PriorityFee)
Output from a local Surfpool network
Output
Is v1: trueCompute unit limit: 20000Priority fee (lamports): 5000
For the full migration guide — including client library support, streaming
(Geyser/gRPC) version detection, and simulation behavior — see the
Transaction Format v1 upgrade page.
Runnable examples in TypeScript, Rust, Python, and Go live in
solana-foundation/upgrades-examples.