tx-indexer
v0.4.1
Published
A TypeScript SDK that transforms raw Solana transactions into human-readable financial data with automatic classification and protocol detection
Downloads
430
Maintainers
Readme
tx-indexer SDK
Solana transaction indexer and classification SDK.
Installation
bun add tx-indexer
# or
npm install tx-indexerQuick Start
import { createIndexer } from "tx-indexer";
const indexer = createIndexer({
rpcUrl: "https://api.mainnet-beta.solana.com"
});
// Get wallet balance
const balance = await indexer.getBalance("YourWalletAddress...");
// Get classified transactions
const txs = await indexer.getTransactions("YourWalletAddress...", {
limit: 10,
filterSpam: true
});
// Get single transaction (no wallet required)
const tx = await indexer.getTransaction("signature...");
// Classification includes sender/receiver
console.log(tx.classification.primaryType); // "transfer", "swap", "nft_mint", etc.
console.log(tx.classification.sender); // sender address
console.log(tx.classification.receiver); // receiver addressTransaction Types
transfer- Wallet-to-wallet transfersswap- Token exchanges (Jupiter, Raydium, Orca)nft_mint- NFT minting (Metaplex, Candy Machine, Bubblegum)stake_deposit- SOL staking depositsstake_withdraw- SOL staking withdrawalsbridge_in- Receiving from bridge (Wormhole, deBridge, Allbridge)bridge_out- Sending to bridgeairdrop- Token distributionsfee_only- Transactions with only network fees
Frontend Integration
Classification is wallet-agnostic. Determine perspective in your frontend:
const { classification } = await indexer.getTransaction(signature);
const connectedWallet = wallet?.address;
if (connectedWallet === classification.sender) {
// "You sent..."
} else if (connectedWallet === classification.receiver) {
// "You received..."
} else {
// "Address X sent to Address Y"
}Bundle Size
The SDK is lightweight and tree-shakeable:
| Import | Size (minified + brotli) |
|--------|----------|
| Full SDK | ~20 KB |
| createIndexer only | ~20 KB |
| classifyTransaction | ~3 KB |
| fetchTransaction | ~4 KB |
| transactionToLegs | ~4 KB |
Check current sizes:
bun run sizeAnalyze why a bundle is large:
bun run size:whyDocumentation
See the main project README for:
- Complete API reference
- Architecture details
- Exported functions
- Usage examples
Development
# Type check
bun run check-types
# Check bundle size
bun run size
# Analyze bundle composition
bun run size:whyLicense
MIT
