The first thing to note is that the closer your protocol is to ENS, the easier it will be to create a blockscout-compatible subgraph. We take initial structure from ENS subgraph. You can take a look at that subgraph and understand structure of our project more precisely.
-
Install just.
Just
is like cmake but better. -
Install python3 and install deps:
just init
-
Now you have to create file inside
protocols
directory decribing your procol. Useexample.protocol.yaml
as template.[EXPEREMENTAL] You can try to generate protocol desription file using
protocol-extractor
. This script will try to extract verified contracts from etherscan and determine their affiliation with the protocol:just try-build-protocol <protocol-name> <etherscan-endpoint-with-api-key> <addresses-of-contracts-comma-separated>
This command will create
protocols/<name>.yaml
file with decription of contracts. You still need to addproject_name
and other metadata field. Also change generated fields it if necessary. -
Generate subgraph project from template:
just template-it-from-protocol protocols/<name>.yaml ../subgraphs
This command will create project inside
../subgraphs/<project_name>
-
Move to recently created directory and run
just init && just codegen
In case of any error, adjust typescript code of subgraph. Also make sure subgraph handles events properly.
-
Write your mappings: read official subgraph guide. You have to handle events of your protocol properly in order to index all blockchain data. You can use default mapping from generated template, however make sure that code is written correctly.
-
Run default tests that will check name hashing logic
# you can ommit -d flag to run tests without docker, but in case of MacOS we suggest you to use docker yarn graph test -d
-
Now build subgraph code
just build
-
Now you should run your subgraph by submitting it to graph-node: read deploy subgraphs to graph-node