Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
选择 slot 更新、区块元数据或筛选后的区块数据,跟踪确认状态并处理数据间隔。
stream.mts
import { subscribe } from "./stream.mts"; for await (const update of subscribe({ slots: { slots: { filterByCommitment: true } }, blocksMeta: { blocks: {} }, })) { if (update.slot) { console.log("slot", update.slot.slot, update.slot.parent, update.slot.status); } if (update.blockMeta) { console.log("block", update.blockMeta.slot, update.blockMeta.blockhash, update.blockMeta.executedTransactionCount); } }
npx tsx slots.mts
filterByCommitment: true
import { subscribe } from "./stream.mts"; const address = process.env.WATCH_ADDRESS; if (!address) throw new Error("Set WATCH_ADDRESS"); for await (const update of subscribe({ blocks: { selected: { accountInclude: [address], includeTransactions: true, includeAccounts: false, includeEntries: false, }, }, })) { if (!update.block) continue; console.log(update.block.slot, update.block.transactions.length); }
此页面对您有帮助吗?