The Graph Builders Newsletter - 18
🏗️ to The Graph Builders Newsletter 🏗️
gm web3 builders,
Welcome to The Graph Builders Newsletter #18 for June 2024! 🏗️
New CLI Features
Publish Subgraphs from the CLI
Ever built a subgraph and wanted to simply publish straight from the terminal instead of navigating to Subgraph Studio?
Now we can!
graph publish
is now live with graph-cli 0.73.0
!
Publish using Arbitrum One GRT with:
graph publish –protocol-network:arbitrum-one –subgraph-id:<Qm…>
Publish using Arbitrum Sepolia testnet GRT with:
graph publish –protocol-network:arbitrum-sepolia –subgraph-id:<Qm…>
graph publish
can not only publish new subgraphs but new versions as well!
Go ahead and upgrade and check out graph publish –help
for more instructions.
New Subgraph Features
If you haven’t had a chance to try out these new features, give them a try!
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.
New Explorer Features
The Graph Explorer has a host of new features to check out. There’s a brand new UI, filtering of subgraphs by category, and a new quickstart section to get builders started querying subgraphs fast!
Indexing Rewards Unlocked
Indexing Rewards for Base, Binance, Scroll & Linea have been enabled. Look out for increased levels of activity and decentralization on these chains’ subgraphs 👀
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 !
Core Devs are Hiring
Ever want to help build The Graph?
Check out these and apply to join a core dev team that’s building The Graph!
Thanks for reading and happy hacking! 💌
Marcus Rein
Developer Relations
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 70+ 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 eight of the many organizations within The Graph ecosystem.