Canonical: https://solanashreds.xyz/learn/inner-instructions-and-cpi

# Inner instructions: the calls you will not find in the raw transaction

Solana inner instructions are produced during execution, so raw transactions never contain them. What CPI means and what a decoder can infer.

Solana inner instructions are the calls one program makes to another while a transaction runs, known as cross-program invocations. The runtime records them in the transaction's execution metadata, not in the transaction. A decoder reading raw transactions, from shreds or anywhere else before execution, sees only the top-level instructions the sender signed.

## What a cross-program invocation is

A program can call another program in the middle of its own instruction, passing along some of its accounts and new instruction data. The token program is the usual target: a swap program moves tokens by invoking SPL Token on the user's behalf, and a router invokes several swap programs one after another. Each of those calls is a cross-program invocation, or CPI.

What the callee receives looks exactly like an instruction: a program, a list of accounts and some data. The difference is who wrote it. A top-level instruction was written by the sender and signed. An inner instruction was produced by a program at run time, and it may depend on account state, prices or earlier results that the sender never wrote down.

## Where inner instructions are recorded

When a validator executes a transaction, it collects every CPI into the transaction's status metadata as `innerInstructions`: a list grouped by the index of the top-level instruction that caused them, each with a stack height showing how deep the call was. RPC returns them with `getTransaction` and `getBlock`, and Geyser plugins receive them with the transaction status.

None of this exists until execution. An entry, the unit a block is shredded into, holds a hash count, a hash and the signed transactions, and nothing else.

## One routed swap, seen from both sides

This Jupiter route comes from mainnet slot 470,901,816. Its seventh top-level instruction, at index 6, calls Jupiter v6. Here is what each side can show you:

| | From the raw transaction | From execution metadata |
| --- | --- | --- |
| Instructions visible | 8 top-level instructions | the same 8, plus 6 inner instructions under index 6 |
| Programs reached by the route | Jupiter v6 only | Meteora DLMM (3 calls), SPL Token (2 calls), Jupiter v6 (1 call to itself) |
| Deepest call | not knowable | stack height 3 |
| Tokens actually moved | not knowable | the two SPL Token transfers |

Inner instructions are not rare. In the two blocks we sampled, 272 of 502 successful transactions had at least one, with about nine on average.

## emit_cpi events are inner instructions too

Anchor programs can publish structured events in two ways. `emit!` writes the event to the program log. `emit_cpi!` makes the program call itself with the event as instruction data, prefixed by a fixed eight-byte tag, so the event survives even where logs are truncated. The self-call in the example above is that pattern.

Either way, the event is produced at run time. A log line and a self-CPI both live in execution metadata, so neither is in the raw transaction. [Program events](https://solanashreds.xyz/learn/solana-program-events) covers how to read them once you have the metadata, and [logs or instruction data](https://solanashreds.xyz/learn/logs-vs-instruction-data) compares the two sources.

## What you can still infer from the top level

The top-level instructions are not empty of meaning. From them a decoder can read:

- which program the sender called, and so the kind of action: a swap, a transfer, a launch;
- the sender's own arguments, for example how much goes in and the least it will accept back;
- the accounts the sender named, which usually identify the pool, the mint and the user;
- for a router, the route plan the sender asked for, when its instruction data spells it out.

What you cannot read is anything decided during execution: the amount actually received, the exact path a router took if it chose at run time, or the transfers a program made on its own authority. Treat those as unknown until you [reconcile with RPC](https://solanashreds.xyz/docs/pipeline/reconcile).

## Why a shred decoder never sees them

Shreds carry the block as the leader broadcast it, before any validator has run it. That is why they are early, and it is also why inner instructions cannot be in them: they do not exist yet. No amount of decoding work recovers them from the bytes. A design that needs inner calls either waits for execution data or pairs the early view with a later one; [what your decoder cannot see](https://solanashreds.xyz/blog/what-your-decoder-cannot-see) lists the other fields in the same situation.

## Questions about inner instructions

### Why does my decoder miss token transfers inside swaps?

Because the swap program makes those transfers through CPI at run time. They appear only in execution metadata. Your decoder sees the swap instruction the sender signed, not the transfers it caused.

### Is a CPI the same as an inner instruction?

Yes, in practice. A CPI is the act of one program calling another; the inner instruction is the record of that call in the transaction's metadata.

### Can I get inner instructions from a managed stream?

From streams built on executed data, yes. The trade-off against raw shreds is laid out in [a raw feed or a managed stream](https://solanashreds.xyz/compare/raw-shreds-vs-managed-streams).

## Where inference stops

Top-level decoding tells you intent, not outcome. If your application needs exact amounts received, fees paid to intermediaries, every token movement, or proof that the call succeeded, raw shreds cannot supply it on their own. You need executed data for those fields. The [FAQ](https://solanashreds.xyz/faq) answers what the feed itself delivers.

## Getting the inner calls after the fact

[Reconciling with RPC](https://solanashreds.xyz/docs/pipeline/reconcile) shows how to attach outcomes, including inner instructions, to the transactions you decoded early. For where else Solana data comes from, see the [map of Solana data sources](https://solanashreds.xyz/learn/solana-data-sources), and for decoding the route instruction itself, [the Jupiter recipe](https://solanashreds.xyz/docs/programs/jupiter). To see which top-level instructions arrive before execution, [decode a first transaction from raw shreds](https://solanashreds.xyz/docs/quickstart).
