decodeTransactionFromRpcResponse

Call Signature

function decodeTransactionFromRpcResponse<
    TMaxSupportedTransactionVersion,
>(rpcTx): Readonly<{
    compiledMessage: CompiledTransactionMessage &
        Readonly<{
            lifetimeToken: string;
        }>;
    loadedAddresses: LoadedAddresses;
    transaction?: Readonly<{
        messageBytes: TransactionMessageBytes;
        signatures: SignaturesMap;
    }>;
}> &
    object;

Decodes a getTransaction response (any of encoding: 'base64', 'base58', or 'json') into a CompiledTransactionMessage plus, for 'base64' and 'base58', a re-encodable Transaction. The JSON path does not produce a Transaction: the server has already decompiled the wire format, so there are no message bytes to carry.

'jsonParsed' is not supported — its instructions arrive pre-parsed by the server and lack raw bytes, so they cannot be round-tripped through the auto-generated parseXInstruction clients. Passing a 'jsonParsed' response throws SOLANA_ERROR__TRANSACTION_INTROSPECTION__CANNOT_DECODE_JSON_PARSED_TRANSACTION; any other unrecognized input throws SOLANA_ERROR__TRANSACTION_INTROSPECTION__UNRECOGNIZED_GET_TRANSACTION_RESPONSE.

A response carrying a transaction version this package cannot decode throws SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED — raised by the JSON path for an unrecognized version, and by the wire decoders for malformed binary input.

Use this together with getInstructionsFromCompiledTransactionMessage (or walkInstructions) to inspect a confirmed transaction's instructions in a form the auto-generated @solana-program/* clients can parse directly.

Prefer encoding: 'base64' when bandwidth allows — it is the most compact, the wire bytes round-trip cleanly through the kit codecs, and the return type statically guarantees a re-encodable transaction.

Type Parameters

Type ParameterDefault type
TMaxSupportedTransactionVersion extends void | TransactionVersionvoid | TransactionVersion

Parameters

ParameterType
rpcTxGetTransactionApiResponseBase64<TMaxSupportedTransactionVersion>

Returns

Readonly<{ compiledMessage: CompiledTransactionMessage & Readonly<{ lifetimeToken: string; }>; loadedAddresses: LoadedAddresses; transaction?: Readonly<{ messageBytes: TransactionMessageBytes; signatures: SignaturesMap; }>; }> & object

Example

const rpcResponse = await rpc.getTransaction(signature(txid), {
    commitment: 'confirmed',
    encoding: 'base64',
    maxSupportedTransactionVersion: 0,
}).send();
if (!rpcResponse) throw new Error('not found');
 
const { compiledMessage, loadedAddresses } = decodeTransactionFromRpcResponse(rpcResponse);
const instructions = getInstructionsFromCompiledTransactionMessage(compiledMessage, loadedAddresses);

Call Signature

function decodeTransactionFromRpcResponse<
    TMaxSupportedTransactionVersion,
>(rpcTx): Readonly<{
    compiledMessage: CompiledTransactionMessage &
        Readonly<{
            lifetimeToken: string;
        }>;
    loadedAddresses: LoadedAddresses;
    transaction?: Readonly<{
        messageBytes: TransactionMessageBytes;
        signatures: SignaturesMap;
    }>;
}> &
    object;

Decodes a getTransaction response (any of encoding: 'base64', 'base58', or 'json') into a CompiledTransactionMessage plus, for 'base64' and 'base58', a re-encodable Transaction. The JSON path does not produce a Transaction: the server has already decompiled the wire format, so there are no message bytes to carry.

'jsonParsed' is not supported — its instructions arrive pre-parsed by the server and lack raw bytes, so they cannot be round-tripped through the auto-generated parseXInstruction clients. Passing a 'jsonParsed' response throws SOLANA_ERROR__TRANSACTION_INTROSPECTION__CANNOT_DECODE_JSON_PARSED_TRANSACTION; any other unrecognized input throws SOLANA_ERROR__TRANSACTION_INTROSPECTION__UNRECOGNIZED_GET_TRANSACTION_RESPONSE.

A response carrying a transaction version this package cannot decode throws SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED — raised by the JSON path for an unrecognized version, and by the wire decoders for malformed binary input.

Use this together with getInstructionsFromCompiledTransactionMessage (or walkInstructions) to inspect a confirmed transaction's instructions in a form the auto-generated @solana-program/* clients can parse directly.

Prefer encoding: 'base64' when bandwidth allows — it is the most compact, the wire bytes round-trip cleanly through the kit codecs, and the return type statically guarantees a re-encodable transaction.

Type Parameters

Type ParameterDefault type
TMaxSupportedTransactionVersion extends void | TransactionVersionvoid | TransactionVersion

Parameters

ParameterType
rpcTxGetTransactionApiResponseBase58<TMaxSupportedTransactionVersion>

Returns

Readonly<{ compiledMessage: CompiledTransactionMessage & Readonly<{ lifetimeToken: string; }>; loadedAddresses: LoadedAddresses; transaction?: Readonly<{ messageBytes: TransactionMessageBytes; signatures: SignaturesMap; }>; }> & object

Example

const rpcResponse = await rpc.getTransaction(signature(txid), {
    commitment: 'confirmed',
    encoding: 'base64',
    maxSupportedTransactionVersion: 0,
}).send();
if (!rpcResponse) throw new Error('not found');
 
const { compiledMessage, loadedAddresses } = decodeTransactionFromRpcResponse(rpcResponse);
const instructions = getInstructionsFromCompiledTransactionMessage(compiledMessage, loadedAddresses);

Call Signature

function decodeTransactionFromRpcResponse<
    TMaxSupportedTransactionVersion,
>(rpcTx): DecodedRpcTransaction;

Decodes a getTransaction response (any of encoding: 'base64', 'base58', or 'json') into a CompiledTransactionMessage plus, for 'base64' and 'base58', a re-encodable Transaction. The JSON path does not produce a Transaction: the server has already decompiled the wire format, so there are no message bytes to carry.

'jsonParsed' is not supported — its instructions arrive pre-parsed by the server and lack raw bytes, so they cannot be round-tripped through the auto-generated parseXInstruction clients. Passing a 'jsonParsed' response throws SOLANA_ERROR__TRANSACTION_INTROSPECTION__CANNOT_DECODE_JSON_PARSED_TRANSACTION; any other unrecognized input throws SOLANA_ERROR__TRANSACTION_INTROSPECTION__UNRECOGNIZED_GET_TRANSACTION_RESPONSE.

A response carrying a transaction version this package cannot decode throws SOLANA_ERROR__TRANSACTION__VERSION_NUMBER_NOT_SUPPORTED — raised by the JSON path for an unrecognized version, and by the wire decoders for malformed binary input.

Use this together with getInstructionsFromCompiledTransactionMessage (or walkInstructions) to inspect a confirmed transaction's instructions in a form the auto-generated @solana-program/* clients can parse directly.

Prefer encoding: 'base64' when bandwidth allows — it is the most compact, the wire bytes round-trip cleanly through the kit codecs, and the return type statically guarantees a re-encodable transaction.

Type Parameters

Type ParameterDefault type
TMaxSupportedTransactionVersion extends void | TransactionVersionvoid | TransactionVersion

Parameters

ParameterType
rpcTxGetTransactionApiResponseJson<TMaxSupportedTransactionVersion>

Returns

DecodedRpcTransaction

Example

const rpcResponse = await rpc.getTransaction(signature(txid), {
    commitment: 'confirmed',
    encoding: 'base64',
    maxSupportedTransactionVersion: 0,
}).send();
if (!rpcResponse) throw new Error('not found');
 
const { compiledMessage, loadedAddresses } = decodeTransactionFromRpcResponse(rpcResponse);
const instructions = getInstructionsFromCompiledTransactionMessage(compiledMessage, loadedAddresses);

On this page