This is a repo used for synchronize a NFT Marketplace backend with TheGraph for listening to the emited Smart Contract events from Patrick Alpha's fcc. The backend repo can be found here and the frontend repo can be found here.
The workshop followed to complete this repo is this one.
The repo that we are going to implement is like this one
We are using TheGraph for reading the events. Steps:
- Index events with TheGraph ✅.
- Read indexed events from TheGraph ✅.
¿ How to use TheGraph ? -> Contracts must be verified on Etherscan.
- Go to TheGraph.
- Connect Metamask
- Change to Smart Contracts deployed network (maybe Rinkeby)
- Create subGraph studio
- Create a new git repository for your subGraph
- Install Graph CLI:
sudo yarn global add @graphprotocol/graph-cli
- Initialize subGraph (change the name):
graph init --studio nftgraphmarketplace
- Execute (change name):
mv nftgraphmarketplace/* ./
and marketplace-nft-fcc folder.
- Modify
schema.graphql
with your events info and new tables that you want to create. - Every time you modify
schema.graphql
-> Execute:
graph codegen
-
Modify
nft-marketplace.ts
insidesrc
. -
Go to
subprah.yaml
and include after abi:startBlock: deployedcontractBlock -1
-
Deploy subGraph (change name last command):
graph auth --studio XXX
graph codegen && graph build
graph deploy --studio nftgraphmarketplace
- Version label: v0.0.1
✅ SUBGRAPH DEPLOYED!!
- You can now start executing scripts from your backend and now your subGraph should be able to listen to these events.