The Graph Builders Newsletter - 17
🏗️ to The Graph Builders Newsletter 🏗️
gm web3 builders,
Welcome to The Graph Builders Newsletter #17 for May 2024! 🏗️
New Features of graph-node
0.35.1
graph-node 0.35.1 is in Subgraph Studio and will soon be on The Graph Network! Check out these three useful and time saving features in Subgraph Studio today!
Speed up Indexing of eth_calls
With Declarative eth_calls
Minimize the runtime overhead of unavoidable eth_calls
by declaring them in the manifest. Declared calls are performed in parallel before handlers run, reducing total time spent compared to sequential execution.
Currently, eth_calls
can only be declared for event handlers. Here’s an example of how to declare a call in the manifest:
The declaration syntax is Contract[address].function(params)
. Use event.address
and event.params.<name>
as values for address and params. The handler accesses the result by binding to the contract and making the call, with results cached in memory for efficiency.
Note: Declared eth_calls
are supported in subgraphs with specVersion >= 1.2.0
.
Check if an Address is a Contract or EOA with hasCode()
With the new hasCode()
function from the ethereum module, available from apiVersion ≥ 0.0.9
, we can easily check is an address is a smart contract or an EOA in our mappings.ts
.
This opens up opportunities for filtering of addresses from within the subgraph, leading to increased accuracy and capabilities from within our subgraphs.
This function returns a boolean, allowing you to implement specific logic based on address type, enhancing the security and functionality of your dApp.
Precise Filtering with Indexed Argument Filters / Topic Filters
Topic filters, also known as indexed argument filters, are a powerful feature in subgraphs that allow for precise filtering of blockchain events based on their indexed arguments. This enables subgraphs to efficiently focus on relevant data, which is particularly useful for tracking specific addresses and their interactions with smart contracts. Available from specVersion >= 1.2.0
.
Imagine the possibilities: you can also track direct transfers between two addresses or monitor all transactions in either direction between two addresses.
When a smart contract emits an event, indexed arguments can be used as filters. For example:
In your subgraph manifest, configure topic filters like this:
This setup filters Transfer events to monitor transactions involving the specified address as either the sender or receiver.
Ecosystem Announcements
The Graph as AI Infrastructure
Semiotic Labs’ new white paper introduces AI services Inference and Agent. Read the , try out the Agentc demo, and get a preview of the future of The Graph + AI.
Learning Corner
Are You Following Subgraph Best Practices?
Here are four Subgraph Best Practices that will improve your subgraphs performance.
Here’s a quick example of one of these best practices:
Best Practice 1: Faster Query Speed with Subgraph Pruning
Used in the manifest, indexerHints can easily prune your subgraph’s database, increasing efficiency and query speed.
Now the subgraph will automatically prune stale data, leading to improved query speed.
Dive into the other Subgraph Best Practices and improve your subgraph’s performance!
- Thursdays 5pm UTC
Jump into every Thursday at 5pm UTC in The Graph’s Discord hosted by Edge & Node Developer Relations Marcus Rein.
Each session includes live workshops and Q&A discussions with developers who are building in The Graph Ecosystem.
Learn to build better with recordings of past episodes of !
Developer Survey
Building The Graph Network is a collaborative effort, and the core devs would love to hear your !
Thanks for reading and happy hacking! 💌
Marcus Rein
Developer Relations and Success
Edge & Node, working on The Graph
About The Graph
is the source of data and information for the decentralized internet. As the original decentralized data marketplace that introduced and standardized subgraphs, The Graph has become web3’s method of indexing and accessing blockchain data. Since its launch in 2018, tens of thousands of developers have for dapps across 90+ blockchains - including Ethereum, Solana, Arbitrum, Optimism, Base, Polygon, Celo, Fantom, Gnosis, and Avalanche.
As demand for data in web3 continues to grow, The Graph enters a with a more expansive vision including new data services and query languages, ensuring the decentralized protocol can serve any use case - now and into the future.
Discover more about how The Graph is shaping the future of decentralized physical infrastructure networks (DePIN) and stay connected with the community. Follow The Graph on , , , , , and . Join the community on The Graph’s , join technical discussions on The Graph’s .
oversees The Graph Network. The Graph Foundation is overseen by the . , , , , , and are seven of the many organizations within The Graph ecosystem.