Awesome
loot-subgraph
Configure a TheGraph Subgraph for Realms and other Lootverse primitives which enables querying bags and transfer data.
Installation
- Intall dependencies:
npm install
- Generate mapping artifacts:
npm run codegen
- Build the subgraph:
npm run build
Folder Structure
Contract addresses live in /config/
with a .json file for each chain.
Subgraphs live in the /subgraphs/ecosystem
folder, organized by chain. For example /subgraphs/ecosystem/layer1
has all Eth mainnet files.
Extending for other projects
To add other projects (e.g. Crypts and Caverns) to this subgraph:
- Copy base contract abi into
subgraphs/ecosystem/layer1/abis/<yourproject>.abi
- Add your contract address and start block into
config/mainnet.json
andconfig/rinkeby.json
- Update
subgraphs/ecosystem/layer1/subgraph.template.yaml
with a new- kind
entry for your contract - Add your schema to
subgraphs/ecosystem/layer1/schema.graphql
- Add a new variable for your project to
transferEvent()
insubgraphs/ecosystem/layer1/schema.graphql
- Edit
subgraphs/ecosystem/layer1/src/<yourproject>-mapping.ts
to map your contract to your schema - Add a new variable for
fromWallet.<yourproject>Held
andtoWallet.<yourproject>Held
tosubgraphs/ecosystem/layer1/src/utils.js
Testing your changes
- Change directory to
subgraphs/ecosystem/layer1
- Run
npm run prepare:rinkeby
from that folder - Generate mapping artifacts from base contract:
npm run codegen
- Verify that your