In this tutorial, you'll learn how to initialize a World Chain-based Substreams project using the Substreams CLI (substreams init command).
The CLI installation is supported only on Linux and macOS. If you're using Windows, consider using the DevContainer environment, which launches a Linux-based virtual environment.
Step 1: Initialize Your World Chain Substreams Project
Running substreams init will give you the option to choose between two EVM project options. Select the one that best fits your requirements:
evm-hello-world: Creates a simple Substreams that outputs the events of a smart contract. For World Chain, this will typically use a common smart contract address available on the network.
evm-events-calls: Creates a Substreams that extracts and decodes EVM events and calls using the cached EVM Foundational Module, filtered by one or more smart contract addresses. Contract ABIs are retrieved from Etherscan-compatible block explorers. If an ABI isn't available, you'll need to provide it yourself.
Step 2: Configure Your World Chain Endpoint
When running your Substreams commands, use the World Chain endpoint:
Run substreams auth to create your account and generate an authentication token (JWT), then pass this token back as input.
Run substreams build to compile the project.
Run substreams gui -e mainnet.worldchain.streamingfast.io:443 to visualize and iterate on your extracted data.
Step 3.5: (Optionally) Transform the Data
Open the src/lib.rs file that has been generated.
Modify the transformations made to the data as needed. Every time you modify the code, you will have to recompile the project with substreams build.
Step 4: Load the Data
To make your Substreams queryable (as opposed to direct streaming), you can automatically send the data to a SQL database by using the SQL sink or through PubSub.
World Chain Specifics
World Chain is an EVM-compatible blockchain, which means: