TL;DR: One of the developers from BuildersDAO shares insights about Substreams composability, including a demo where he demonstrates the integration of Chainlink Substreams.
Learn more about Graph BuildersDAO and watch member Thomas demo the benefits of Substreams’ composability.
Graph Builders Office Hours
The mission of the Graph Builders Office Hours is to support and empower developers, teams, and protocols actively building with The Graph protocol.
Sessions are hosted by developers working in The Graph ecosystem and each session includes a live workshop and Q&A discussion.
Introduction to Graph BuildersDAO
There would be no Builders Office Hours without Graph BuildersDAO.
What’s BuildersDAO?
BuildersDAO is a network of developers who specialize in building subgraphs and Substreams. The DAO serves as a hub where new and existing protocols can request the creation of subgraphs or Substreams.
How it works:
- Requests: Protocols come to them with their needs—whether it’s data indexing, analytics, or other Graph-related tasks.
- Bounties: A bounty is set for the project, and skilled developers can apply to take it on.
- Building: Developers work on it, creating high-quality subgraphs or Substreams.
- Rewards: Once complete, developers receive their well-deserved bounty.
They’re always on the lookout for talented developers to join the DAO. If you’re a passionate web3 builder, consider applying through the website.
🎤 Guest speaker
This Graph Builders Office Hours session features Thomas, a builder and DAO developer, sharing insights from his recent project related to Substreams composability.
📺 You can watch the entire recorded session on The Graph’s YouTube—check it out!
Discussion
Main goal of BuildersDAO:
- The primary objective of the BuildersDAO is to foster the growth of The Graph ecosystem. The DAO achieves this by engaging with individuals who require subgraph or Substreams development.
- Not only do they actively seek out those in need, but they also connect with developers who might be considering other providers. Their aim is to encourage them to return to The Graph ecosystem.
Substreams are composable:
- Substreams offers a powerful feature: composability. Think of it as building with LEGO blocks. When a developer creates Substreams, others can easily incorporate them into their own work.
- Instead of manually integrating code, you can import existing Substreams like LEGO pieces. For instance, you might start with the Uniswap V2 version, build upon it, and then deploy your customized Substreams.
- Other developers can then build on top of your creation.
Substreams Registry:
- After building your Substreams, head over to the Substreams Registry. Here, you can upload your Substreams, making them easy for others to find.
- The registry provides an interface where you can explore existing Substreams and find additional details.
Demo
Integrate a Chainlink price store into Substreams to get the price of ETH in USD
During his presentation, Thomas demonstrated how to build Substreams using the Substreams framework and the lio smart contract as an example to track the events emitted by the contract.
Thomas demonstrated the integration of the Chainlink Substreams by retrieving the real-time price of Ethereum (ETH) in USD.
The key steps he followed:
- Import the necessary Substreams: He imported the lio contract Substreams and the Chainlink price Substreams.
- Define the initial block: He specified the initial block from which the Substreams should start processing data.
- Create a new module: He created a new module called map_usd_value to process the events from the lio contract and add the USD price information. This module takes two input parameters: events from lio contract and chainlink_price_store module output from Chainlink Substreams package.
- Access the Chainlink price store: In the map_usd_value map handler he used chainlink_price_store module output to access the price of ETH.
- Process the events: He looped through the events emitted by the lio contract and calculated the USD value for each event using the ETH price obtained from the Chainlink store.
- Output the results: The processed events with the USD value are emitted as the output of the Substreams. Now that module can be plugged into the downstream module, such as graph_out, to be consumed by a subgraph or any other sink.
For more live workshops and step-by-step demos, join the Builders Office Hours every Thursday at 17:00 UTC (12:00 ET) on The Graph Discord.
💡 This article answers questions like: - Why is it good that Substreams are composable? - What is Graph BuildersDAO? - How does a developer use existing Substreams from the registry?
Great piece, Wisdom! Thanks for explaining this so well. I never thought of mixing Lego and Substreams before!