中文 | English | 官网 | Telegram | Discord
☕ 支持本项目
本 SDK 完全免费且开源。但维护和持续更新需要消耗大量 AI 算力与 Token。如果这个 SDK 对您的开发有帮助,欢迎每月捐赠任意数量的 SOL,您的支持将帮助这个项目持续运行!
捐赠钱包:
6oW7AXz1yRb57pYSxysuXnMs2aR1ha5rzGzReZ1MjPV8
| 语言 | 仓库 |
|---|---|
| Rust | sol-parser-sdk |
| Node.js | sol-parser-sdk-nodejs |
| Python | sol-parser-sdk-python |
| Go | sol-parser-sdk-golang |
npm
npm install sol-parser-sdk-nodejs@0.4.4源码(monorepo 里目录可能是 sol-parser-sdk-ts)
git clone https://github.com/0xfnzero/sol-parser-sdk-nodejs
cd sol-parser-sdk-nodejs
npm install
# npm run build # 若从 dist 引用而非 tsx 跑 examples,再执行在包根目录(与 package.json 同级):
cp .env.example .env
# 填写 GRPC_URL、GRPC_TOKEN在该目录下执行下面的 npx tsx,以便加载 .env。
npx tsx scripts/test-grpc-ts.ts需要 GRPC_URL、GRPC_TOKEN。更多变量见 .env.example(如 MAX_EVENTS、TIMEOUT_MS)。
import {
YellowstoneGrpc,
parseDexEventsFromGrpcTransactionInfo,
dexEventToJsonString,
} from "sol-parser-sdk-nodejs";
const ENDPOINT = process.env.GRPC_URL?.trim() ?? "";
const X_TOKEN = process.env.GRPC_TOKEN?.trim() ?? "";
if (!ENDPOINT || !X_TOKEN) throw new Error("GRPC_URL and GRPC_TOKEN are required");
const client = new YellowstoneGrpc(ENDPOINT, X_TOKEN);
const filter = {
account_include: [
"6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P", // PumpFun
"pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA", // PumpSwap
],
account_exclude: [],
account_required: [],
vote: false,
failed: false,
};
const sub = await client.subscribeTransactions(filter, {
onUpdate: (update) => {
const txInfo = update.transaction?.transaction;
if (!txInfo?.transactionRaw || !txInfo.metaRaw) return;
const slot = update.transaction!.slot;
const events = parseDexEventsFromGrpcTransactionInfo(txInfo, slot, undefined);
for (const ev of events) console.log(dexEventToJsonString(ev, 2));
},
onError: (err) => console.error(err.message),
onEnd: () => {},
});
console.log("subscribed", sub.id);更轻量:仅用日志用 parseLogsOnly;要补账户可再配合 applyAccountFillsToLogEvents。
使用 SHREDSTREAM_URL / SHRED_URL(默认 http://127.0.0.1:10800)或命令行 --url,不用 GRPC_URL。
客户端在 TypeScript 中解码 gRPC entries 负载(布局与 Go shredstream/entries_decode 一致),并用 @solana/web3.js 反序列化线格式交易,无需 WebAssembly / wasm-pack。
npx tsx examples/shredstream_example.ts -- --url=http://127.0.0.1:10800shredstream_pumpfun_json.ts 另需 Solana RPC_URL(或 --rpc)解析 ALT。
在包根目录执行,npm install 后即可。示例用 npx tsx 直接加载 src/,不必先 npm run build。源码列每个文件单独一行,链接指向 GitHub 上的对应源码(GitHub / npm 均可点击)。
| 描述 | 运行命令 | 源码 |
|---|---|---|
| 本包脚本 | ||
gRPC 集成测试(PumpFun + PumpSwap,账户填充后的 DexEvent) |
npx tsx scripts/test-grpc-ts.ts |
test-grpc-ts.ts |
调试:打印 metaRaw / 日志结构 |
npx tsx scripts/debug-grpc-ts.ts |
debug-grpc-ts.ts |
| PumpFun | ||
gRPC 输出完整 JSON DexEvent |
npx tsx examples/pumpfun_grpc_json.ts |
pumpfun_grpc_json.ts |
| PumpFun 事件 + 性能指标 | npx tsx examples/pumpfun_with_metrics.ts |
pumpfun_with_metrics.ts |
| PumpFun 交易类型过滤 | npx tsx examples/pumpfun_trade_filter.ts |
pumpfun_trade_filter.ts |
| PumpFun 快速连接测试 | npx tsx examples/pumpfun_quick_test.ts |
pumpfun_quick_test.ts |
| PumpSwap | ||
gRPC 输出完整 JSON DexEvent |
npx tsx examples/pumpswap_grpc_json.ts |
pumpswap_grpc_json.ts |
| PumpSwap 事件 + 性能指标 | npx tsx examples/pumpswap_with_metrics.ts |
pumpswap_with_metrics.ts |
| PumpSwap 超低延迟 | npx tsx examples/pumpswap_low_latency.ts |
pumpswap_low_latency.ts |
| Meteora DAMM | ||
| Meteora DAMM V2 事件 | npx tsx examples/meteora_damm_grpc.ts |
meteora_damm_grpc.ts |
| ShredStream(HTTP,非 Yellowstone gRPC;端点见上文步骤 5) | ||
超低延迟订阅、队列与延迟统计。端点:--url / SHREDSTREAM_URL / .env(默认 http://127.0.0.1:10800)。 |
npx tsx examples/shredstream_example.ts |
shredstream_example.ts |
ShredStream → PumpFun DexEvent JSON;需 Solana RPC 解析 ALT(RPC_URL 或 --rpc)。 |
npx tsx examples/shredstream_pumpfun_json.ts |
shredstream_pumpfun_json.ts |
| 多协议 | ||
| 同时订阅所有 DEX 协议 | npx tsx examples/multi_protocol_grpc.ts |
multi_protocol_grpc.ts |
| 工具 | ||
| 验证 onUpdate 同步错误不会打断 gRPC 流 | npx tsx examples/grpc_onupdate_error_test.ts |
grpc_onupdate_error_test.ts |
按签名解析交易(parseTransactionFromRpc;非 gRPC)。在 .env 或环境中设置 TX_SIGNATURE。 |
npx tsx examples/parse_tx_by_signature.ts |
parse_tx_by_signature.ts |
npm run 别名(与上表 ShredStream 行同一源码文件,每行一条):
npm run example:shredstream→ shredstream_example.tsnpm run example:shredstream:subscribe→ shredstream_example.tsnpm run example:shredstream:pumpfun-json→ shredstream_pumpfun_json.ts
环境变量: gRPC 示例需要 GRPC_URL、GRPC_TOKEN。ShredStream 使用 SHREDSTREAM_URL / SHRED_URL 或 --url;shredstream_pumpfun_json 另需 RPC_URL / --rpc。详见 .env.example。
PumpFun、PumpSwap、Raydium AMM V4 / CLMM / CPMM、Orca Whirlpool、Meteora DAMM V2 / DLMM、Bonk Launchpad(见 src/instr/)。
parseDexEventsFromGrpcTransactionInfo— 需要transactionRaw+metaRaw(与 Rust gRPC 对齐)。parseRpcTransaction/parseTransactionFromRpc— HTTP RPC 全量解析。dexEventToJsonString— 含 BigInt 的安全 JSON 输出。
npm run build
npm run check:migration # 对齐与校验,需先 build