Prerequisites
- Node.js 22+ installed
- TypeScript project initialized
1
Download and install
Install the Pipes SDK package.
2
Create the script
Create a file
index.ts with the code listed below:index.ts
3
Run the script
Execute the script to start indexing swap instructions.You should see swap instructions printed to the console:
Complete Code
View complete code with explanations
View complete code with explanations
The complete code retrieves and decodes Orca Whirlpool swap instructions from Solana mainnet.
index.ts
How it works
- Portal source:
solanaPortalSourceconnects to the Portal API and streams Solana blockchain data - Decoder:
solanaInstructionDecoderfilters and decodes program instructions using ABIs - Pipe:
.pipe()chains the decoder to the source - Stream: The
for awaitloop processes batches of decoded data as they arrive
Data structure
Each decoded swap instruction contains:blockNumber: Slot number where the instruction occurredtimestamp: Block timestampprogramId: Program address that executed the instructiontransaction: Transaction details including signaturesinstruction: Decoded instruction fields (accounts, data)rawInstruction: Raw instruction data
Next steps
- Use
range: { from: 'latest' }to stream from the latest slots - Add multiple programs or instruction types
- Use
createTargetto persist data to a database - See Basics for more examples

