Learn · Updated November 18, 2026

How a Solana instruction is stored inside a transaction

Solana instruction data, as stored in a transaction, is compact: one byte naming the program by its position in the account list, a list of one-byte positions for the accounts it uses, and a run of raw bytes whose meaning only that program defines. Decoding raw transactions means turning those positions back into addresses before reading the bytes.

Compiled form and expanded form#

When you build a transaction in a client library, each instruction carries full 32-byte addresses and flags for every account. Before it is signed, the message is compiled: every distinct address goes once into the key list, and instructions keep only small indexes into that list. The compiled form is what travels over the network, what the leader packs into entries, and what you hold when you read shreds.

RPC, when asked for parsed output, rebuilds an expanded view for you: addresses in place of indexes, sometimes a decoded name and arguments. That view is convenient, but it is a reconstruction. A raw decoder works from the compiled form and does the rebuilding itself.

The program ID index#

The first field is a single byte, the position of the program's address in the key list. The program is an account like any other in that list, and the runtime treats the address it finds there as the program to call.

Two rules hold for every valid message. The index never points at position 0, because that slot belongs to the fee payer, and a program cannot pay. In a v0 transaction it never points into a lookup table either: the message code rejects program IDs loaded from lookup tables, so the program is always one of the keys written in the transaction. That lets you identify every top-level program without fetching any on-chain state, which is the basis of reading program IDs.

The account index list#

Next comes the list of accounts the instruction passes to the program, one byte each. Each byte points into the full account list: the static keys first, then, for a v0 transaction, the writable addresses loaded from lookup tables, then the read-only ones.

The order of this list is part of the instruction's meaning. A token transfer does not label its source and destination; the program simply expects the source first and the destination second, and the decoder must know that convention. Whether each account is a signer or writable comes from the message header, not from the instruction.

The data bytes#

Last is a length and then the data itself. The runtime never interprets these bytes; it hands them to the program. Programs pick their own layout, and three patterns cover most of what you will meet:

  • a one-byte tag, then fixed fields (SPL Token, Raydium AMM v4);
  • a four-byte little-endian tag (the System program);
  • an eight-byte Anchor discriminator, then the arguments in Borsh.

Nothing in the data says which pattern applies. You learn it from the program you resolved through the program index.

One token transfer, from indexes to meaning#

This instruction comes from a legacy transaction in mainnet slot 470,901,816. Its compiled form is just numbers:

FieldRaw valueMeaning
Program index8Key 8 is TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA, SPL Token
Account indexes3, 9, 4, 1TransferChecked expects source, mint, destination, owner, in that order
Data, byte 00cTag 12: TransferChecked
Data, bytes 1 to 80017dfa117000000Amount, u64 little-endian: 101,500,000,000 base units
Data, byte 909Decimals: 9, so the amount is 101.5 tokens

Every piece of meaning in the right-hand column came from knowledge outside the instruction: the key list for the program, the SPL Token layout for the account order, the tag and the field sizes.

Why compiled form is all a shred decoder gets#

From shreds you never receive the expanded form. Each instruction arrives as indexes and bytes, and for a v0 transaction some of those indexes point past the static keys into accounts you have not resolved yet. A decoder needs three things before it can say what an instruction did: the full account list, the program's data layout, and the program's account order. The Anchor instruction decoding guide shows the second and third steps in code.

One transaction can also hold many instructions for many programs. One transaction, many instructions looks at how to treat them.

Questions about instruction data#

What is instruction data?#

The bytes a program receives with one instruction. The program alone defines what they mean; they usually begin with a tag or discriminator that selects the operation.

Can two instructions in one transaction call different programs?#

Yes. Each instruction has its own program index, and a transaction often mixes compute budget, token and DEX instructions.

Why do my account indexes point past the end of the key list?#

The transaction is v0 and those accounts come from lookup tables. Resolve the tables first, then index into the combined list.

What instruction data cannot show#

Instruction data records what the sender asked for, not what happened. It cannot show the amount a swap actually returned, the calls the program made to other programs, or whether the instruction failed. Those come from execution results, which a decoder starting from shreds does not have.

From instruction bytes to program meaning#

Instructions sit inside the layout described in what is inside a Solana transaction. To see where this step falls among all the others, follow the decoding pipeline, and the program-by-program decoding recipes take each layout further. Your first end-to-end decode is in the getting-started guide.

Sources#

Raw shreds on your own server

Ultra Low Latency Shreds is $200 and Standard Shreds is $100. You pay in crypto, tell us which IPv4 address and UDP port should receive the stream, and we wire it up by hand.