DEV Community

Cover image for How to query USDC data in real-time with Ormi
Wen-Chiao
Wen-Chiao

Posted on

How to query USDC data in real-time with Ormi

Subgraphs let you query on-chain data with GraphQL, eliminating the need for crawling logs or relying on RPC calls. With Ormi’s 0xGraph, anyone can deploy and query subgraphs in just a few steps, completely free.

This tutorial will guide you through creating and deploying a subgraph that indexes USDC (ERC-20) transfers on Ethereum mainnet.

What you’ll need

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 Ormi and sign in.
  2. From the dashboard, create an API key for deployments.

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

Running Subgraph CLI

Run the Graph CLI init flow:

graph init usdc-subgraph
Enter fullscreen mode Exit fullscreen mode

When prompted:

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

Setting up the Subgraph

cd <subgraph-name>
Enter fullscreen mode Exit fullscreen mode
graph codegen
Enter fullscreen mode Exit fullscreen mode


graph build
Enter fullscreen mode Exit fullscreen mode

Deploy the Subgraph to Ormi

Return to your API page and copy the information to paste it in the section below.

graph deploy <graph-name> --node  https://subgraph.api.ormilabs.com/deploy --ipfs https://subgraph.api.ormilabs.com/ipfs --deploy-key <API key>
Enter fullscreen mode Exit fullscreen mode

Track sync status

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

Query your USDC subgraph

Click into the specific Subgraph

Enable the private GraphQL box to query via GraphQL link

Keep in mind that headers need to include your API key and if it doesn’t, you will not be able to make queries

{
  "Authorization": <API key>
}
Enter fullscreen mode Exit fullscreen mode

Example query for most recent transfer events:


query LatestTransfers {
  transfers(first: 5, orderBy: blockTimestamp, orderDirection: desc) {
    id
    from
    to
    blockTimestamp
  }
}
Enter fullscreen mode Exit fullscreen mode

Conclusion

You just deployed a USDC subgraph via Ormi’s 0xgraph. From here, you can add the endpoint to your app to reflect real-time activity on USDC transfers.

About Ormi

Ormi is the next-generation data layer for Web3, purpose-built for real-time, high-throughput applications like DeFi, gaming, wallets, and on-chain infrastructure. Its hybrid architecture ensures sub-30ms latency and up to 4,000 RPS for live subgraph indexing.

With 99.9% uptime and deployments across ecosystems representing $50B+ in TVL and $100B+ in annual transaction volume, Ormi is trusted to power the most demanding production environments without throttling or delay.

Related Resources

Top comments (0)