Creating a Subgraph

Create your subgraph from scratch or an existing contract.

💡

If you already have a subgraph and are looking to deploy it on Alchemy Subgraphs, see Deploying a Subgraph.

From Scratch

To create a subgraph from scratch:

graph init --product hosted-service

From an Existing Contract

To create a subgraph that indexes all events of an existing contract:

graph init \
  --product hosted-service
  --from-contract <CONTRACT_ADDRESS> \
  [--network <ETHEREUM_NETWORK>] \
  [--abi <FILE>] \
  <subgraph name>

The ABI will be fetched from Etherscan. If it can't be found, the --abi file will need to be specified.

From an Example Subgraph

Alchemy Subgraphs has several example subgraphs for you to instantly deploy. See your dashboard to get started.

ReadMe