> ## Documentation Index
> Fetch the complete documentation index at: https://ormilabs.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How to deploy a USDC subgraph with The Graph CLI

> This tutorial will gude you through creating and deploying a USDC (ERC-20) subgraph with The Graph CLI.

> [!NOTE]
>
> If you plan to update or redeploy your subgraph in the future, create and use a tag before you start querying the endpoint.
> [Tags](https://ormilabs.com/docs/subgraphs/manage-and-monitor/tags.md) let you hot-swap new deployments under the same URL later without changing your front-end code.

## What you'll need

* An [Ormi Labs account](https://app.ormilabs.com/)
* [Graph CLI installed](https://www.npmjs.com/package/@graphprotocol/graph-cli) `npm install -g @graphprotocol/graph-cli`
* [node.js installed](https://nodejs.org/en)
* [Git installed](https://git-scm.com/downloads/win)
* The USDC contract on Ethereum mainnet: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48

**Tip**: USDC launched on Ethereum in Sept 2018; you can confirm addresses per chain in Circle’s docs if you ever target other networks.

## Getting started

1. Go to the [Ormi App](https://app.ormilabs.com) and login.
2. From the dashboard, create an API key for deployments.

![0xGraph API Keys](https://mintcdn.com/ormilabs/QF_fmnEzWAEcNv02/images/0xgraph-api-key.png?fit=max\&auto=format\&n=QF_fmnEzWAEcNv02\&q=85\&s=ac4ade1e29e7be09629130b131f3dd1b)

API Keys

Keep this page open, we’ll need the API key to deploy a subgraph.

## Running the subgraph CLI

Open your terminal and run The Graph CLI init flow:

```
graph init usdc-subgraph
```

![0xGraph graph init](https://mintcdn.com/ormilabs/vcU9W8gg4MUmMgRt/images/how-to/cli-graph-init-1.png?fit=max\&auto=format\&n=vcU9W8gg4MUmMgRt\&q=85\&s=b78bf8ed5e0dc57701872d827a8c4004)

API Keys

When prompted:

![0xGraph graph init](https://mintcdn.com/ormilabs/vcU9W8gg4MUmMgRt/images/how-to/cli-graph-init-2.png?fit=max\&auto=format\&n=vcU9W8gg4MUmMgRt\&q=85\&s=c8c6df75bf431aafbb0ce21281b46baa)

API Keys

1. **Network**: Ethereum Mainnet
2. **Source**: Smart contract: Ethereum
3. **Subgraph slug**: `create your own name`
4. **Contract address**: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
5. **Contract name**: `create your own name`
6. **Start block**: (optional but recommended)

## Setting up the subgraph

```
cd <subgraph name>
```

```
graph codegen
```

![0xGraph graph init](https://mintcdn.com/ormilabs/vcU9W8gg4MUmMgRt/images/how-to/cli-graph-codegen.png?fit=max\&auto=format\&n=vcU9W8gg4MUmMgRt\&q=85\&s=65159f24638237bbe0a073566644e252)

API Keys

```
graph build
```

![0xGraph graph init](https://mintcdn.com/ormilabs/vcU9W8gg4MUmMgRt/images/how-to/cli-graph-build.png?fit=max\&auto=format\&n=vcU9W8gg4MUmMgRt\&q=85\&s=b3f3fa2ea0b0043ea0a1abbc397a622f)

API Keys

## Deploy the subgraph to 0xGraph

Return to your [API page](https://app.ormilabs.com/dashboard/api) and copy the information to paste it in the `API key` section below.

```
graph deploy <graph-name> --node  https://subgraph.api.ormilabs.com/deploy --ipfs https://subgraph.api.ormilabs.com/ipfs --deploy-key <API key>
```

![0xGraph graph init](https://mintcdn.com/ormilabs/vcU9W8gg4MUmMgRt/images/how-to/cli-graph-deploy.png?fit=max\&auto=format\&n=vcU9W8gg4MUmMgRt\&q=85\&s=c9bd9481d0ac4b67ef7e9c29525be48a)

API Keys

## Track sync status

You can check syncing in the dashboard by going to the Subgraphs tab:

![0xGraph graph init](https://mintcdn.com/ormilabs/vcU9W8gg4MUmMgRt/images/how-to/cli-graph-sync.png?fit=max\&auto=format\&n=vcU9W8gg4MUmMgRt\&q=85\&s=059494b6496d79326a1852fc1eb690ee)

API Keys

## Find the GraphQL link

Click the URL button and a graphql link will pop up. Click the graphql link.

![0xGraph graph init](https://mintcdn.com/ormilabs/vcU9W8gg4MUmMgRt/images/how-to/cli-graph-graphql.png?fit=max\&auto=format\&n=vcU9W8gg4MUmMgRt\&q=85\&s=71e95b5652b6cb8909015373fa6773a8)

API Keys

## Query your USDC subgraph

```
query LatestTransfers {
  transfers(first: 5, orderBy: blockTimestamp, orderDirection: desc) {
    id
    from
    to
    blockTimestamp
  }
}
```

![0xGraph graph init](https://mintcdn.com/ormilabs/vcU9W8gg4MUmMgRt/images/how-to/cli-graphql-query.png?fit=max\&auto=format\&n=vcU9W8gg4MUmMgRt\&q=85\&s=27b586ae3ebe87dd133425527051e592)

API Keys

## You're all set up!

## Next steps

![query subgraph icon](https://mintcdn.com/ormilabs/qV2VfGqVCCe99Ked/images/icons/scan.svg?fit=max\&auto=format\&n=qV2VfGqVCCe99Ked\&q=85\&s=e45e14abccf8d0fec7df137623baa1ab)

How to query a subgraph

Learn how to run GraphQL queries to fetch smart contract data from deployed subgraphs.

[Open](https://ormilabs.com/docs/docs/subgraphs/query-data/querying-a-subgraph)

&#x20;

![monitor subgraph icon](https://mintcdn.com/ormilabs/qV2VfGqVCCe99Ked/images/icons/monitor-check.svg?fit=max\&auto=format\&n=qV2VfGqVCCe99Ked\&q=85\&s=4955d6d9d247161fb8fe84ae89ce1203)

How to monitor your subgraph

Learn how to monitor your subgraph syncing progress and logs after deployment.

[Open](https://ormilabs.com/docs/docs/subgraphs/manage-and-monitor/monitor-subgraph)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.