Skip to content
English
Versioned Transactions are the transaction formats that allow for additional functionality in the Solana runtime, beyond what the original legacy format supports. While changes to onchain programs are NOT required to support the new functionality of versioned transactions (or for backwards compatibility), developers WILL need update their client side code to prevent errors due to different transaction versions.

​Current Transaction Versions

The Solana runtime supports three transaction versions:
VersionSize limitAddress Lookup TablesResource limits
legacy1,232 bytesNot supportedComputeBudget instructions
01,232 bytesSupportedComputeBudget instructions
14,096 bytesRemovedSet in the message config
Jump to the format you are building with: For the wire layout of each format, see versioned transactions.

​Max supported transaction version

All RPC requests that return a transaction should specify the highest version of transactions they will support in their application using the maxSupportedTransactionVersion option, including getBlock and getTransaction. An RPC request will fail if a Versioned Transaction is returned that is higher than the set maxSupportedTransactionVersion. (i.e. if a version 0 transaction is returned when legacy is selected)
WARNING: If no maxSupportedTransactionVersion value is set, then only legacy transactions will be allowed in the RPC response. Therefore, your RPC requests WILL fail if any version 0 transactions are returned. The same applies one version up: requests that set 0 will fail on version 1 transactions. Set the value to the integer 1 to support every format.

​How to set max supported version

You can set the maxSupportedTransactionVersion using both the @solana/web3.js library and JSON formatted requests directly to an RPC endpoint.

​Using web3.js

Using the @solana/web3.js library, you can retrieve the most recent block or get a specific 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.

​JSON requests to the RPC

Using a standard JSON formatted POST request, you can set the maxSupportedTransactionVersion when retrieving a specific block. Slot 518104023 holds legacy, v0 and v1 transactions; any recent slot from getSlot works too:

​V0 transactions

Version 0 transactions can be created similar to the older method of creating transactions. There are differences in using certain libraries that should be noted. Below is an example of how to create a Versioned Transaction, using the @solana/web3.js library, to send perform a SOL transfer between two accounts.
@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.

​Notes:

  • payer is a valid Keypair wallet, funded with SOL
  • toAccount a valid Keypair
Firstly, import the web3.js library and create a connection to your desired cluster. We then define the recent blockhash and minRent we will need for our transaction and the account:
Create an array of all the instructions you desire to send in your transaction. In this example below, we are creating a simple SOL transfer instruction:
Next, construct a MessageV0 formatted transaction message with your desired instructions:
Then, create a new VersionedTransaction, passing in our v0 compatible message:
You can sign the transaction by either:
  • passing an array of signatures into the VersionedTransaction method, or
  • call the transaction.sign() method, passing an array of the required Signers
NOTE: After calling the transaction.sign() method, all the previous transaction signatures will be fully replaced by new signatures created from the provided in Signers.
After your VersionedTransaction has been signed by all required accounts, you can send it to the cluster and await the response:
NOTE: Unlike legacy transactions, sending a VersionedTransaction via sendTransaction does NOT support transaction signing via passing in an array of Signers as the second parameter. You will need to sign the transaction before calling connection.sendTransaction().

​V1 transactions

Version 1 raises the transaction size limit to 4,096 bytes and moves the resource limits out of ComputeBudget instructions and into the message itself. Address Lookup Tables are not available on v1 — every account a v1 transaction touches is listed in the message.

​Building a v1 transaction

A v1 message is assembled through the same pipeline as a legacy or v0 one; the difference is the config it carries. The compute unit limit and loaded accounts data size limit both default to zero, so a v1 transaction that leaves them unset always fails.
Kit
Output from a local Surfpool network
Output

​Estimating the resource limits

Rather than hardcoding the limits, simulate the transaction to measure them. Simulation runs with both limits raised to the runtime maximum, so it cannot fail for want of the resources it is measuring.
Kit
Output from a local Surfpool network
Output
The estimate is the exact cost of one simulated run, with nothing to spare. Add a margin before relying on it in production.

​Reading a v1 transaction

Fetching a v1 transaction requires setting maxSupportedTransactionVersion to the integer 1. The compiled message stores the config as a bitmask plus a positional list, so decompile it to address the fields by name.
Kit
Output from a local Surfpool network
Output

​More Resources