stream.mts。以下示例使用相同的环境变量与依赖。
订阅 entry 元数据
entries.mts
读取 entry 字段
slot与index标识 entry 在 slot 内的位置。hash为二进制数据,示例以十六进制显示。numHashes记录 entry 的哈希次数。executedTransactionCount是计数,不是交易数组。startingTransactionIndex表示其第一笔交易在区块中的索引。
BigInt。交易计数可以为零。
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
订阅 entry 哈希、索引和交易计数。需要完整交易数据时,使用交易或区块订阅。
stream.mts。以下示例使用相同的环境变量与依赖。
import { subscribe } from "./stream.mts";
for await (const update of subscribe({ entry: { entries: {} } })) {
const entry = update.entry;
if (!entry) continue;
console.log({
slot: entry.slot,
index: entry.index,
hash: Buffer.from(entry.hash).toString("hex"),
numHashes: entry.numHashes,
transactionCount: entry.executedTransactionCount,
startingTransactionIndex: entry.startingTransactionIndex,
});
}
npx tsx entries.mts
slot 与 index 标识 entry 在 slot 内的位置。hash 为二进制数据,示例以十六进制显示。numHashes 记录 entry 的哈希次数。executedTransactionCount 是计数,不是交易数组。startingTransactionIndex 表示其第一笔交易在区块中的索引。BigInt。交易计数可以为零。
此页面对您有帮助吗?