Subgraph Deploy

Deploy the Cron Protocol subgraph to The Graph Studio.

Prerequisites

  • Graph CLI: npm install -g @graphprotocol/graph-cli
  • A deployed CronRegistry contract (testnet or mainnet)
  • The Graph Studio account at thegraph.com/studio

1. Configure subgraph

Run the configure script to update subgraph/subgraph.yaml with your registry address and network:

bash
cd codebase
./scripts/configure-addresses.sh \
  --registry 0xYOUR_REGISTRY \
  --chain baseSepolia \   # or base, arbitrum, arbitrumSepolia
  --start-block 12345678

Verify subgraph/subgraph.yaml shows the correct address, network, and startBlock.

2. Create subgraph in Studio

  1. Go to The Graph Studio
  2. Click Create a Subgraph
  3. Name it cron-protocol
  4. Select your network (Base Sepolia or Base)
  5. Copy the deploy key from the Studio dashboard

3. Authenticate and deploy

bash
cd codebase/subgraph

# Authenticate with your deploy key from Studio
graph auth --studio YOUR_DEPLOY_KEY

# Install dependencies
npm install

# Generate types from schema
graph codegen

# Build
graph build

# Deploy
graph deploy --studio cron-protocol

4. Get the query URL

After deployment, The Graph Studio shows your subgraph's query URL:

https://api.studio.thegraph.com/query/YOUR_ID/cron-protocol/version/latest

Set this as the env var in your Vercel dashboard deployment:

bash
NEXT_PUBLIC_SUBGRAPH_URL=https://api.studio.thegraph.com/query/YOUR_ID/cron-protocol/version/latest

[i] Indexing time

The subgraph starts indexing from startBlock. On Base Sepolia, expect full sync within 5–15 minutes depending on how far back the start block is. Check sync status in The Graph Studio under your subgraph's “Indexing Status” tab.

5. Test your queries

Use The Graph Studio's built-in GraphQL playground to verify data is indexing correctly:

graphql
{
  protocolStats(id: "GLOBAL") {
    totalPlans
    totalSubscriptions
    activeSubscriptions
  }
}

Updating the subgraph

After any contract redeployment or schema change, rebuild and redeploy:

bash
graph codegen && graph build && graph deploy --studio cron-protocol