This document outlines the steps to configure and deploy the ENS Subgraph.
-
Open the
subgraph.yamlFile- Navigate to the root directory of your project and open the
subgraph.yamlfile.
- Navigate to the root directory of your project and open the
-
Specify the Network
- Modify the
networkfield to reflect the network on which your smart contract is deployed. You can find the available network names here. - Replace with:
Example:
network: cli-name
network: mbase
- Modify the
-
Update Smart Contract Address and Start Block
- In the
dataSourcessection, change theaddressandstartBlockfields to correspond to your specific smart contract. ThestartBlocktypically represents the block in which the contract was created. The configuration should look as follows:- kind: ethereum/contract name: MetadataService network: mbase source: address: "YOUR_METADATA_SERVICE_ADDRESS" abi: MetadataService startBlock: SMART_CONTRACT_CREATION_BLOCK mapping: kind: ethereum/events apiVersion: 0.0.6 language: wasm/assemblyscript file: ./src/MetadataService.ts entities: - MetadataService abis: - name: MetadataService file: ./abis/MetadataService.json eventHandlers: - event: "MetadataUpdate(uint256,string)" handler: handleMetadataUpdate
- Important Note: Ensure that you replace the
addressandstartBlockwith the correct values for your contract. Always verify the name before making replacements.
- In the
-
Example Configuration
- kind: ethereum/contract name: MetadataService network: mbase source: address: "0x452606a3176441753776766DBb51AE85136f4148" abi: MetadataService startBlock: 8883486 mapping: kind: ethereum/events apiVersion: 0.0.6 language: wasm/assemblyscript file: ./src/MetadataService.ts entities: - MetadataService abis: - name: MetadataService file: ./abis/MetadataService.json eventHandlers: - event: "MetadataUpdate(uint256,string)" handler: handleMetadataUpdate
-
Update the
src/utils.tsFile- Open the
src/utils.tsfile and modify the following constants:export const ETH_NODE_TEXT = ".YOUR_DOMAIN"; export const ETH_NODE = "NAMEHASH_OF_YOUR_DOMAIN";
- Example Update:
export const ETH_NODE_TEXT = ".ns3"; export const ETH_NODE = "0x212790ef3397c94de29376f58ecc41f1267661e3453d54551570a5dfb58d630d";
- Open the
-
Generate Types
- To generate types, run the following command:
npm run codegen
- To generate types, run the following command:
-
Build the Subgraph
- To build the subgraph, execute:
npm run build
- To build the subgraph, execute:
-
Authenticate for Deployment
- Before deploying the subgraph, you need to authenticate. Use the following command, replacing
YOUR_KEYwith your actual authentication key obtained from the subgraph project:graph auth --studio YOUR_KEY
- Before deploying the subgraph, you need to authenticate. Use the following command, replacing
-
Deploy the Subgraph
- After authentication, deploy the subgraph using one of the following commands:
- If you have copied the deploy command from the The Graph dashboard:
graph deploy --studio 3ns
- Or, you can use:
npm run deploy
- If you have copied the deploy command from the The Graph dashboard:
- After authentication, deploy the subgraph using one of the following commands:
-
Deployment Confirmation
- After executing the deploy command, your subgraph will be deployed successfully.