Define subgraph for crawling data from blockchain.
- Refer from project guide (Refer Link)
Install Graph CLI using NPM
npm install -g @graphprotocol/graph-cliInstall Graph CLI using Yarn
yarn global add @graphprotocol/graph-cliAuthenticate in CLI
graph auth --studio [api key]Build subgraph
graph codegen && graph buildDeploy subgraph
graph deploy --studio test-subItems to update each time build~deploy:
- network: set cli name of network (Refer Link)
- source/address: set appropriate address of contract that deployed on the network.
- source/startBlock: set block number
Refer content of [./subgraph.yaml] file
dataSources:
- kind: ethereum
name: AddCollectionSC
network: polygon-amoy
source:
address: "0xf499483d090dd097010B659dc29db83FB143A00e"
abi: AddCollectionSC
startBlock: 5960501
mapping:
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- Collection
abis:
- name: AddCollectionSC
file: ./abis/AddCollectionSC.json
eventHandlers:
- event: AddCollection(address)
handler: handleAddCollection
file: ./src/mapping.ts