Rebuilding The Graph Cli – Integrating Sourcify for Verified & Open Smart Contract Data

The Graph By Apr 02, 2025 No Comments
TL;DR: The Graph CLI has integrated Sourcify, replacing Etherscan as the default contract verification source. This update automates contract lookups, fetches ABIs, and enhances decentralization by allowing developers to contribute verified contracts. Developers benefit from a more seamless experience when building subgraphs.

We sat down with Etienne, a developer here at Pinax, to discuss the latest updates to The Graph CLI, how it builds on The Graph Registry, and the new integration with Sourcify. This partnership enhances contract verification, improves decentralization, and streamlines the developer experience.

Please check out our previous blog on The Graph Registry, Mo Networks, Mo Solutions: The Power of The Graph Networks Registry.

What is The Graph CLI?

The Graph CLI is an essential tool for developers working with subgraphs in The Graph ecosystem. CLI stands for Command Line Interface. It is a text-based interface used to interact with software or systems by typing commands rather than using a graphical user interface (GUI).

It simplifies the process of building, managing, and deploying subgraphs by providing a streamlined interface for interacting with blockchain data. With the latest update, The Graph CLI has taken a significant step forward by integrating with Sourcify, an open-source contract verification platform and founding member of The Verifier Alliance.

Graph CLI is a tool that Graph developers can use to manage, build and deploy subgraph projects. It also allows developers to test their subgraphs, fetch APIs from contracts and scaffold project structures efficiently”
– said Etienne

Screenshot for an example for what to expect when initializing your Subgraph

Screenshot for an example for what to expect when initializing your subgraph

Why Integrate Sourcify?

Previously, developers relied on Etherscan as the primary provider for contract data. While useful, this approach had limitations, especially when dealing with decentralized data and verification. Sourcify offers a decentralized alternative, providing a robust database of verified smart contracts and their metadata.

One of the main reasons for integrating Sourcify was to move away from Etherscan’s API. Sourcify provides an open-source alternative with a massive database of verified contracts, ensuring that the deployed contract code matches the source code”
– Etienne explained

How Does Sourcify Improve The Graph CLI?

The integration with Sourcify enhances The Graph CLI in several key ways:

  • Automated Contract Lookup: When a developer inputs a contract address, The Graph CLI now automatically fetches the verified ABI and other metadata from Sourcify.
  • Better Metadata Storage: Sourcify stores metadata such as contract creation blocks and implementation details, reducing the need for manual input.
  • Improved Decentralization: Any developer can contribute contract verifications to Sourcify, aligning with The Graph’s goal of decentralization.

With Sourcify, we can provide a standard way of retrieving contract information. Developers can see if a contract is a proxy, find its implementation, and access additional metadata—all within the CLI”
– said Etienne

What Happens if a Contract Isn’t Verified?

While Sourcify covers over 90% of Ethereum smart contracts, there may be cases where a contract isn’t found in the database.
In such cases, The Graph CLI will:

  1. Attempt a fallback to Etherscan to retrieve the necessary information.
  2. Prompt the developer to manually input missing data, such as the contract name or ABI file path.
  3. Allow developers to submit their contracts to Sourcify, contributing to a growing repository of verified contracts.

If the contract isn’t verified, developers can manually provide the ABI and contract details. But with Sourcify, we have reduced the need for this significantly” – Etienne noted

Were there any Challenges?

The process wasn’t without its challenges.

The first time we wanted to integrate Sourcify, we analyzed their database and found that they were missing a lot of older contracts. Their system was great at tracking new deployments, but historical data gaps made it difficult for full coverage.” – Etienne explained

Over the course of time Pinax worked closely with Sourcify to backfill missing contract metadata, ensuring a smoother experience for developers using The Graph CLI.

What’s Next?

The team is actively working on a new command, graph contract, which will allow developers to query contract metadata directly. This will provide:

  • Enhanced visibility into contract properties and structures.
  • The ability to extract contract metadata into files for further analysis.
  • A seamless developer experience when working with subgraphs.

We’re excited to introduce graph contract, which will fetch and display contract metadata right in the CLI. This will help developers gain deeper insights into smart contracts while maintaining a fully open-source approach”
– Etienne shared

Wrapping up

The integration of Sourcify marks a significant step in improving The Graph CLI, making it more decentralized, automated, and developer-friendly. By moving away from centralized APIs and embracing open-source solutions, The Graph continues to empower developers in building a more open and efficient web3 ecosystem.

For developers looking to take advantage of these improvements, simply update The Graph CLI to the latest version and start exploring the enhanced contract lookup features powered by Sourcify.


5 Questions This Article Answers

5 Questions This Article Answers

  • What is The Graph CLI, and why is it essential for subgraph developers?
  • Why was Sourcify integrated into The Graph CLI instead of continuing with Etherscan?
  • How does Sourcify improve the developer experience in The Graph CLI?
  • What happens if a smart contract isn’t verified on Sourcify?
  • What’s coming next for The Graph CLI after Sourcify integration?

Author

I am a dedicated member of the Graph Advocates DAO and proud to be a part of the Graphtronauts community. As a passionate crypto investor and enthusiast, I have delved into the world of decentralized technologies, with a strong focus on The Graph protocol. My journey includes writing insightful blogs for Graphtronauts and contributing to the development of subgraph documentation for various projects within The Graph ecosystem. Most recently, I have taken on the role of a Pinax technical writer, further expanding my commitment to advancing the adoption and understanding of blockchain and Graph-based technologies. /n https://twitter.com/PaulBarba12 https://github.com/PaulieB14 https://hey.xyz/u/paulieb https://medium.com/@paulieb.eth/about

No Comments

Leave a comment

Your email address will not be published. Required fields are marked *