Hello everyone, this is Petko (Axiomatic Aardvark on Discord) from LimeChain. I would like to bring to your attention an idea that we’ve been tossing around for a bit with folks from The Graph Foundation (namely @Pedro).
In a nutshell
It would be awesome to have a plugin for Hardhat, which smart contract developers (and subgraph developers of course) can utilise in order to automate away some of the manual tasks associated with subgraph development.
The pitch
Hardhat has been around for a while and has become one of the most widely used (if not the most widely used) framework for developing smart contracts on Ethereum. Given The Graph’s exponential popularity growth we can assume that a lot of new contracts being developed will incorporate subgraphs early on in their architecture. We expect to see a rise of something like subgraph-driven development of smart contracts. Meaning that smart contract devs will consciously strive to write their contracts in an event-first fashion, using little functions to none at all. This creates a need for a Hardhat plugin, which can abstract away the manual tasks related to creating and updating your subgraph.
How the plugin will work
Let’s imagine that a developer sits down to write a smart contract using Hardhat. They initialise their project from a Hardhat template and then update the template contract accordingly. After the initial setup is complete and they have a basci contract in place, they can run the following:
npx hardhat graph
which will automatically create a subgraph folder in the root of their Hardhat project, and populate it with a basic structure (copied from the Example Subgraph, for instance). The command would also generate the schema.json
, subgraph.yaml
, mapping.ts
, and other files files accordingly, based on the contents of Hardhat’s artifacts
build folder.
If however there’s already a subgraph folder, the plugin/tool will update only the bits that have changed.
Request for feedback
Now that we’ve gone over the basics of the Hardhat plugin concept, there is so much room for other functionality that can be added to further automate the process of subgraph development, based on the developers needs. All questions, comments and functionality requests are more than welcome!
PS the POC repo for this idea is located here. We will be using it to track progress, receive feedback in the form of Issues, etc.