- Clone repo
git clone https://github.com/decent-dao/fractal-subgraph
- Install dependencies
npm install
- Generate types and entities (this will generate types and entities based on the schema and handlers defined in the subgraph.yaml file)
npm run codegen -f subgraph.<network>.yaml
- Make sure that network is supported from Subgraph Studio. Note - the chain might be not listed, but still supported. Check graphprotocol Discord.
- Create
subgraph.<network>.yaml
in the repository root. Copy-paste content from one of existing configuration files. Adjust contractaddress
es,network
andstartBlock
fields. - Create new Subgraph Studio instance from the Studio
- Update
package.json
withdeploy:<network>
script. - Deploy newly created Subgraph instance (see next section).
- Open the PR to merge your changes with all the created/updated configuration into
main
branch.
- Authorize for deployment. You can get
<DEPLOY KEY>
from the Subgraph Studio.npx graph auth --studio <DEPLOY KEY>
- Generate static build.
npm run codegen:sepolia npm run build:sepolia
- Do the Deployment. It will prompt you for version.
npm run deploy:sepolia
There're 3 main parts of this repository:
- GraphQL Schema: used to define schema of entitines that are stored in Subgraph.
- Subgraph Config: central place of configuration of The Graph service. Used to define handlers and data source (aka smart contracts to read events from). Also, defines which handlers to call in regard of events
- Handlers: actual code, where you define handlers and how they react to events (creating/updating/deleting entities)