Skip to content

Latest commit

 

History

History
57 lines (36 loc) · 2.35 KB

File metadata and controls

57 lines (36 loc) · 2.35 KB

Howto create subgraph for your domain name protocol

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.

  1. Install just. Just is like cmake but better.

  2. Install python3 and install deps:

    just init
  3. Now you have to create file inside protocols directory decribing your procol. Use example.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 add project_name and other metadata field. Also change generated fields it if necessary.

  4. Generate subgraph project from template:

    just template-it-from-protocol protocols/<name>.yaml ../subgraphs

    This command will create project inside ../subgraphs/<project_name>

  5. 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.

  6. 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.

  7. 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
  8. Now build subgraph code

    just build
  9. Now you should run your subgraph by submitting it to graph-node: read deploy subgraphs to graph-node