Subgraphs
Shadow RPCs support the read methods required by most subgraph services.
You can run a local subgraph pointed to a Shadow RPC today, and we're actively working on integrations with hosted subgraph providers.
Why use Shadow with subgraphs?
You can significantly reduce the time to resync your subgraph by moving pieces of indexing logic into custom shadow events. For example, if your subgraph currently:
Uses bindings to call contract view functions for state data
Uses any
callHandlers
Recreates contract logic in AssemblyScript to arrive at required values
Then you'll be able to make your subgraph sync much faster with Shadow.
Instead of making slow and expensive RPC calls, relying on function tracing, or writing complex logic in AssemblyScript, you can move everything into simple eventHandlers
with custom shadow events.
Moving indexing logic into Solidity also makes your subgraph more end-to-end testable, reducing the engineering time for releasing new features and debugging indexing problems.
Our team can pair with you to evaluate potential subgraph performance improvements. If you're interested in getting direct support from our engineering team on this, please email fast@shadow.xyz.
Integrations
Local Graph Node
Configure your local node to use your Shadow RPC URL as a provider for your desired chain and include your Shadow API key as part of the provider details by using the `X-SHADOW-API-KEY` custom header. For more info, see The Graph's documentation on local Graph Node configuration.
Step-by-step instructions on setting up a local graph node pointed to your Shadow RPC.
Spin up a local graph node instance; requirements:
Shadow fork URL
Local IPFS instance
Postgres access (local/remote)
Graph CLI
Migrate your shadow contracts to a local solidity project where you can compile the base contract as well as generate respective ABI bindings (e.g. Foundry, Hardhat)
Initialize subgraph project using your local shadow contract instead of pointing to an Etherscan explorer
Verify that your subgraph.yaml manifest:
Points to the appropriate local contract dependencies (i.e, abi.json, source path)
Contains the shadow events in the
eventHandlers
mappingUses the correct onchain address
Create and deploy your local subgraph to your local node; e.g:
graph create --node http://127.0.0.1:8020 SUBGRAPH_NAME
graph deploy SUBGRAPH_NAME --ipfs http://127.0.0.1:5001 --node http://127.0.0.1:8020
Verify that your shadow logs are being indexed by verifying your postgres db. There should be sgd* database schema with unique tables per each contract event id. (e.g, sgd0/transfer)
Last updated