Skip to content

schmidsi/nft-subgraph-open-zeppelin-hashmasks

Repository files navigation

Top Slide

NFT Subgraph Example with Open Zeppelin

Prerequisites

  • Install graph-cli

First Steps

{
  "output": "",
  "chain": "mainnet",
  "datasources": [
    {
      "address": "0xc2c747e0f7004f9e8817db2ca4997657a7746928",
      "startBlock": 11743743,
      "module": "erc721"
    }
  ]
}
  • Run this command:
npx graph-compiler \
  --config config.json \
  --include node_modules/@openzeppelin/subgraphs/src/datasources \
  --export-schema \
  --export-subgraph
  • Inspect the source. Add a description to subgraph.yaml: (Note: this is to make your subgraph hash unique. Tipp: You can just change it to force a resync if needed)
description: "My awesome subgraph"
```yaml
- Add scripts to `package.json`:

```json
{
  "scripts": {
    "build": "graph build",
    "codegen": "graph codegen",
  }
}
  • Fix subgraph.yml 🤯:
file: node_modules/@openzeppelin/contracts/build/contracts/IERC721Metadata.json
  • yarn codegen

  • yarn build

  • https://thegraph.com/en/

  • Go to studio

  • Connect with MetaMask

  • Create a Subgraph

  • graph auth --studio ...

  • Update scripts:

"deploy": "graph deploy --studio hashmasks"
query Test {
  erc721Contracts {
    name
    id
    supportsMetadata
    symbol
  }
  erc721Tokens {
    id
    owner {
      id
    }
    uri
  }
}
  • Publish & signal
  • View on Graph Explorer

Extend the Subgraph

Other resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published