Quickstart: decode your first Solana transaction from raw shreds
From packets arriving on your port to a transaction signature you can look up, in one sitting. One file, one dependency, and every line of it tested against real mainnet blocks.
The quickstart listens on your UDP port, groups the incoming data shreds by slot, rebuilds each block component and prints every transaction it contains as a JSON line: slot, signature, format (legacy, v0 or v1) and the programs it calls. Copy one signature into a Solana explorer and you have checked the whole chain yourself.
Before you start#
- Your own machine, reachable on a public IPv4 address, with the UDP port you chose for the stream. Ordering and activation covers getting one set up.
- Inbound UDP allowed on that port from any source port; the sending port is not fixed.
- Node 24, which runs TypeScript files directly, and npm.
- Packets already arriving. If you are not sure, run the three checks in verify delivery first.
Steps#
- Confirm packets are arriving with the delivery checks.
- In an empty folder, run
npm init -y && npm pkg set type=module && npm install @solana/kit@8.6.0, then save the file below asquickstart.ts. Thetype=modulesetting lets Node load it as an ES module. - Run
node quickstart.ts 8001, using the port your stream arrives on. Lines appear as each block component completes. - Copy a
signaturefrom the output and open it in any Solana explorer. The transaction it shows is the one you just decoded from raw packets.
quickstart.ts#
// Quickstart: print every transaction that arrives on your UDP port, one JSON line each.// Node 24 and @solana/kit 8.6.0 (npm install @solana/kit@8.6.0), then:// node quickstart.ts 8001 listen on UDP port 8001// node quickstart.ts --file saved.shreds read a saved capture (each datagram prefixed by its u16 LE length)import dgram from "node:dgram";import fs from "node:fs";import { getTransactionDecoder, getCompiledTransactionMessageDecoder, getBase58Decoder } from "@solana/kit";const txDecoder = getTransactionDecoder(), messageDecoder = getCompiledTransactionMessageDecoder(), base58 = getBase58Decoder();const DATA_COMPLETE = 0x40;const slots = new Map<bigint, { parts: Map<number, { flags: number; payload: Uint8Array }>; starts: Set<number>; done: Set<number> }>();function onDatagram(buf: Uint8Array) {if (buf.length < 88) return;const kind = buf[64] & 0xf0;if (kind !== 0x90 && kind !== 0xb0) return; // keep data shreds; skip coding shreds and anything elseconst v = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);const slot = v.getBigUint64(65, true), index = v.getUint32(73, true), flags = buf[85], size = v.getUint16(86, true);if (size < 88 || size > buf.length) return;let s = slots.get(slot);if (!s) slots.set(slot, (s = { parts: new Map(), starts: new Set([0]), done: new Set() }));if (s.parts.has(index)) return; // duplicates.parts.set(index, { flags, payload: buf.subarray(88, size) });if (flags & DATA_COMPLETE) s.starts.add(index + 1);for (const start of [...s.starts].sort((a, b) => a - b)) { // a run of shreds ending in DATA_COMPLETE is one block componentif (s.done.has(start)) continue;let end = start;while (s.parts.has(end) && !(s.parts.get(end)!.flags & DATA_COMPLETE)) end++;if (!s.parts.has(end)) continue;s.done.add(start);const component = Buffer.concat([...Array(end - start + 1)].map((_, i) => s.parts.get(start + i)!.payload));printTransactions(slot, component);}}function printTransactions(slot: bigint, c: Uint8Array) {const v = new DataView(c.buffer, c.byteOffset, c.byteLength);let o = 8;for (let e = 0n, entries = v.getBigUint64(0, true); e < entries; e++) { // a zero count is a header or footer markero += 40; // num_hashes and the entry hashconst count = Number(v.getBigUint64(o, true)); o += 8;for (let t = 0; t < count; t++) {const len = txLength(c, o);const tx = txDecoder.decode(c.subarray(o, o + len)); o += len;const m = messageDecoder.decode(tx.messageBytes);const indexes = "instructionHeaders" in m ? m.instructionHeaders.map((h) => h.programAccountIndex) : m.instructions.map((i) => i.programAddressIndex);const sig = Object.values(tx.signatures)[0];console.log(JSON.stringify({ slot: Number(slot), signature: sig ? base58.decode(sig) : "", version: String(m.version),programs: [...new Set(indexes.map((i) => m.staticAccounts[i]))] }));}}}// Where a transaction ends: kit decodes an exact slice, so measure first (legacy, v0, or v1 with its signatures last).function txLength(b: Uint8Array, start: number): number {const v = new DataView(b.buffer, b.byteOffset, b.byteLength);const sv = (o: number): [number, number] => { let x = 0, s = 0; for (;;) { const y = b[o++]; x |= (y & 0x7f) << s; if (!(y & 0x80)) return [x, o]; s += 7; } };if (b[start] === 129) {const ixs = b[start + 40], addrs = b[start + 41];let words = 0; for (let m = v.getUint32(start + 4, true); m; m &= m - 1) words++;const h = start + 42 + 32 * addrs + 4 * words;let o = h + 4 * ixs;for (let i = 0; i < ixs; i++) o += b[h + 4 * i + 1] + v.getUint16(h + 4 * i + 2, true);return o + 64 * b[start + 1] - start;}let o = start, n: number;[n, o] = sv(o); o += 64 * n;const v0 = (b[o] & 0x80) !== 0; if (v0) o++;o += 3; [n, o] = sv(o); o += 32 * n + 32;let k: number; [k, o] = sv(o);for (let i = 0; i < k; i++) { o++; [n, o] = sv(o); o += n; [n, o] = sv(o); o += n; }if (v0) { [k, o] = sv(o); for (let i = 0; i < k; i++) { o += 32; [n, o] = sv(o); o += n; [n, o] = sv(o); o += n; } }return o - start;}if (process.argv[2] === "--file") {const raw = fs.readFileSync(process.argv[3]);for (let o = 0; o < raw.length;) { const n = raw.readUInt16LE(o); o += 2; onDatagram(raw.subarray(o, o + n)); o += n; }} else {const sock = dgram.createSocket({ type: "udp4", recvBufferSize: 64 * 1024 * 1024 });sock.on("message", onDatagram);sock.bind(Number(process.argv[2] ?? 8001), () => console.error(`listening on udp/${process.argv[2] ?? 8001}`));}
Reading the output#
Each line is one transaction:
{"slot":470901815,"signature":"36rFNmu3EShgKrPSipWyK6A8Yn58jWuHYrByCDDJCFVKzLCMiAGu4mFD4hw5zVKABJnenQSYmhbTWUhJfPsUKiuy","version":"1","programs":["Archer8kgiavM61GyusMzaaS2ft5sALtNsD1HxkUPMhy"]}
The signature is the transaction's ID: the first signature in a transaction names it everywhere on Solana, which is why an explorer can find it. version tells you which wire format it used, and programs lists the programs its top-level instructions call. Expect the occasional empty list: our fixtures contain v1 transactions that carry no instructions at all and simply pay a fee.
The file decodes on the same thread that reads the socket, which is fine for a first look. Under a busy stream, move the decoding to a worker thread, as the TypeScript decoder does, so the socket never stalls.
How this was tested#
We replayed two consecutive mainnet blocks, slots 470,901,815 and 470,901,816, shredded by Agave 4.4.1's own Shredder, through this exact file. Tests: node test-quickstart.ts on Node 24.14 with @solana/kit 8.6.0.
| Mode | Result |
|---|---|
--file with each saved slot | 269 of 269 and 512 of 512 transactions, in block order |
| Local replay over UDP at 4,000 datagrams a second (a test rate, not the feed's rate), shuffled, every 5th sent twice | 269 of 269 and 512 of 512, each printed once |
What the output does and does not tell you#
You get what each transaction asked for: its signature, format and the programs it calls. You do not get whether it succeeded, its logs, its balance changes or the calls programs made to each other, because shreds carry none of that. Inner instructions and CPI and what your decoder cannot see cover the gaps.
The quickstart also uses data shreds only. If a packet is lost, the transactions in its block component are skipped; the full decoders rebuild lost pieces from the coding shreds.
Questions#
What do you get from raw shreds?#
The signed transactions, in the sequence the leader packed them into the block: their signatures, instructions and account keys. Execution results such as success, logs and balance changes are not in shreds; they come only after the block is executed.
Why does a transaction show no programs?#
Some v1 transactions on mainnet contain no instructions and only pay a fee. They are real and decode correctly; there is just nothing to list.
Do I need an SDK or an API key?#
No. Delivery goes to your IP address and port, and the only dependency here is the open-source @solana/kit library for decoding transactions.
Next: pick your language#
For a production receiver, take the TypeScript decoder with its worker thread, or the Rust decoder, which also rebuilds lost data shreds from coding shreds. Packets are not data explains each stage in between. To choose a plan for your pipeline, compare Standard or Ultra, then order Standard or Ultra.
Sources#
- Agave v4.4.1 ledger/src/shred.rs: data shred header, variant byte and DATA_COMPLETE flag (checked 2026-11-18)
- Agave v4.4.1 entry/src/block_component.rs: entry batches and markers (checked 2026-11-18)
- @solana/kit 8.6.0 (anza-xyz/kit): transaction and message decoders (checked 2026-11-18)
- SIMD-0385 Transaction V1 Format (checked 2026-11-18)
- Fixtures: mainnet blocks 470,901,815 and 470,901,816 (getBlock), shredded locally with the Agave 4.4.1 Shredder (checked 2026-11-18)
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.