graph-node indexes events in ethereum blockchain
One can submit subgraph to graph-node -- actual code how to handle new events of contracts
-
You may need to add your custom network to
config.toml -
Start your own graph-node with docker-compose:
docker-compose up -d
-
Load small version of ens-rainbow
./rainbow.small.sh
Or use full ens-rainbow dump if you want full domain name resolving
Read guide How to add new subgraph
-
Add your protocol to deployer/config.json
-
Run deployer script to deploy to local graph-node:
just deploy-subgraph <protocol_name>- Run deployer script to deploy to remote graph-node:
just deploy-subgraph --prod <protocol_name>-
Initially:
cd subgraphs/<subgraph_directory> yarn install yarn codegen yarn build
-
[FOR BLOCKSCOUT TEAM] Make sure you have access to graph, for example using port forwarding to staging graph-node:
kubectl port-forward -n graph-node svc/graph-node 8020:8020
Or you can run your own
graph-nodeusing docker: read start locally -
Create subgraph on graph-node
yarn graph create --node http://127.0.0.1:8020 <subgraph_name>
-
Deploy subgraph to graph-node
yarn graph deploy --node http://127.0.0.1:8020 --ipfs http://127.0.0.1:5001 --network <network_name> --version-label 0.0.1 <subgraph_name>
-
Connect to subgraph database and check current state of deployed subgraph:
select deployment, failed, health, synced, latest_ethereum_block_number, fatal_error from subgraphs.subgraph_deployment; select * from subgraphs.subgraph_error; select name, resolved_address, expiry_date from sgd1.domain where label_name is not null and block_range @> 2147483647 order by created_at limit 100;
Note that we selected from custom schema called
sgd1. This schema is created bygraph-nodeand will be automatically incremented tosgd2,sgd3, etc.
- Run
bens-serverAPI and send requests to check results of subgraph: read bens-server docs
Developing subgraph for protocol based on space-id contracts requires providing additional information.
SpaceID protocol has constant variable called identifier which unique describes protocol accross multiple chains.
This values is used during calculation of namehash, therefore subgraph should know this value.
Actually blockscout-ens needs two values that can be calculated from identifier: empty_label_hash and empty_label_hash
empty_label_hashis basically hashedidentifierbase_node_hashis hash ofbase_nodeplusempty_label_hash
To obtain it, you need to make eth_call to Base contract (contract with NFT):
-
mode-sepoliaexampleBASE_NODE=mode \ RPC_URL=https://sepolia.mode.network \ CONTRACT=0xCa3a57e014937C29526De98e4A8A334a7D04792b \ python3 tools/fetch-space-id.py OUTPUTS: identifier: '0x00000397771a7e69f683e17e0a875fa64daac091518ba318ceef13579652bd79' empty_label_hash: '0xea1eb1136f380e6643b69866632ce3b493100790c9c84416f2769d996a1c38b1' base_node_hash: '0x9217c94fd014da21f5c43a1fcae4154a2bbfce43eb48bb33f7f6473c68ee16b6'
-
mode-mainnetexampleRPC_URL=https://mainnet.mode.network \ CONTRACT=0x2ad86eeec513ac16804bb05310214c3fd496835b \ BASE_NODE=mode \ python3 tools/fetch-space-id.py OUTPUTS: identifier: '0x0000868b771a7e69f683e17e0a875fa64daac091518ba318ceef13579652bd79' empty_label_hash: '0x2fd69f9e5bec9de9ebf3468dafc549eca0bc7d17dfbc09869c2cfc3997d5d038' base_node_hash: '0x2f0e9a68fa134a18a7181045c3549d639665fe43df78e882d8adea865a4bb153'
base_node_hashfor subgraph
Put base_node_hash (without 0x prefix) inside utils.ts, for example:
export const BASE_NODE_HASH = "9217c94fd014da21f5c43a1fcae4154a2bbfce43eb48bb33f7f6473c68ee16b6"
Also don't forget to replace this value if you change network (from mainnet to testnet for example)
empty_label_hashfor BENS
Put empty_label_hash in json configuration of BENS.
Use mainnet inside prod.json and testnet staging.json