solana_kit_transaction_introspection 0.9.3 copy "solana_kit_transaction_introspection: ^0.9.3" to clipboard
solana_kit_transaction_introspection: ^0.9.3 copied to clipboard

Decode confirmed Solana transactions and walk their instructions for the auto-generated program clients.

solana_kit_transaction_introspection #

pub package CI coverage

Decode confirmed Solana transactions and walk their outer and inner instructions. walkInstructions returns every instruction in display order, with account indices resolved to AccountMetas ready for the @solana-program/* clients to identify and parse.

Key APIs #

  • decodeTransactionFromRpcResponse(Map<String, Object?>?) decodes a getTransaction response ('base64', 'base58', or 'json') into a DecodedRpcTransaction (compiled message + loaded ALT addresses + wire-format transaction for binary encodings).
  • walkInstructions({compiledMessage, meta, loadedAddresses}) returns every instruction in display order as TracedInstructions (each outer instruction followed by its CPI inner instructions), with account indices resolved to AccountMetas.
  • getInstructionsFromCompiledTransactionMessage(compiledMessage, {loadedAddresses}) returns the outer instructions as resolved Instructions.
  • getInnerInstructionsFromMeta(meta, accountMetas) returns the inner instructions from a getTransaction meta as TracedInstructions.

Usage #

void main() {
  // `rpcTx` is a Map<String, Object?> from a `getTransaction` RPC response.
  // final Map<String, Object?>? rpcTx = await rpc.getTransaction(...);
  // final decoded = decodeTransactionFromRpcResponse(rpcTx);
  // for (final ix in walkInstructions(
  //   compiledMessage: decoded.compiledMessage,
  //   loadedAddresses: decoded.loadedAddresses,
  // )) {
  //   print(ix.trace);
  //   print(ix.programAddress);
  // }
}

'jsonParsed' responses are not supported: their instructions arrive pre-parsed by the server and lack raw bytes, so they cannot be round-tripped through the auto-generated parseXInstruction clients. Prefer 'base64' when bandwidth allows. It is the most compact and the returned transaction is re-encodable.

RPC input is validated fail-closed. Mixed-type account/index arrays, unsupported transaction versions, incomplete compiled instructions, invalid header counts, malformed loaded addresses, duplicate inner-instruction groups, and inner-instruction groups that do not match an outer instruction throw a SolanaError instead of being silently dropped or misattributed.

Account resolution requires the writable and readonly loaded-address counts to match the v0 message's address table lookups exactly. Missing or extra addresses are rejected before instruction indices are resolved; legacy and v1 messages cannot accept loaded addresses. Decoding a response without loaded metadata remains possible, but lookup-dependent account resolution requires complete metadata. These structural checks do not authenticate an RPC provider's account addresses or execution metadata.

0
likes
150
points
2.09k
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Decode confirmed Solana transactions and walk their instructions for the auto-generated program clients.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

meta, solana_kit_addresses, solana_kit_codecs_strings, solana_kit_errors, solana_kit_instructions, solana_kit_transaction_messages, solana_kit_transactions

More

Packages that depend on solana_kit_transaction_introspection