子流
Reading time: 2 min
Substreams is a powerful blockchain indexing technology developed for The Graph Network. It enables developers to write Rust modules, compose data streams alongside the community, and provide extremely high-performance indexing due to parallelization in a streaming-first approach.
With Substreams, developers can quickly extract data from different blockchains (Ethereum, BNB, Solana, ect.) and send it to various locations of their choice, such as a Postgres database, a Mongo database, or a Subgraph. Additionally, Substreams packages enable developers to specify which data they want to extract from the blockchain.
- **您编写了一个Rust程序,定义了要应用于区块链数据的转换操作。**例如,以下的Rust函数从以太坊区块中提取相关信息(区块号、哈希和父哈希)。
fn get_my_block(blk: Block) -> Result<MyBlock, substreams::errors::Error> {let header = blk.header.as_ref().unwrap();Ok(MyBlock {number: blk.number,hash: Hex::encode(&blk.hash),parent_hash: Hex::encode(&header.parent_hash),})}
您只需运行一个命令行命令,就可以将您的Rust程序打包成一个WASM模块。
WASM容器被发送到Substreams端点执行。 Substreams提供商将区块链数据传送给WASM容器,然后执行转换操作。
You select a , a place where you want to send the transformed data (a Postgres database or a Subgraph, for example).
Substreams的官方文档目前由StreamingFast团队维护。
To learn about the latest version of Substreams CLI, which enables developers to bootstrap a Substreams project without any code, please check .