- Create a new subgraph in The Graph Hosted service
You will then have a username/subgraphname that you will use later.
- Clone the repo:
git clone git@github.com:dabit3/erc20-subgraph-starter.git
- Install dependencies
npm install
# or
yarn- Update the
deployscript inpackage.jsonto match the name of your subgraph:
"deploy": "graph deploy --node https://api.thegraph.com/deploy/your-username/your-subgraphname"
# update
your-username/your-subgraphname- Authenticate
graph auth- Deploy
yarn deploy{
accounts {
ERC20balances {
id
value
contract {
name
}
}
}
}{
erc20Contract(id: "0x1234...") { # Replace with vault address
symbol
name
balances(where: { valueExact_gt: "0" }) {
account {
id
}
value
valueExact
}
}
}For queries that require variables, you can pass them like this:
query getVaultHolders($vaultAddress: String!) {
erc20Contract(id: $vaultAddress) {
symbol
name
balances(where: { valueExact_gt: "0" }) {
account {
id
}
value
valueExact
}
}
}Variables:
{
"vaultAddress": "0x1234..." // Replace with actual vault address
}