Deployment

Deployment guide for the Pactum platform on Vercel.


Prerequisites

  • A Vercel account
  • The repository pushed to GitHub
  • A configured Database project with all migrations applied
  • A deployed PactumBilling smart contract on Arc Testnet

Vercel Deployment

1. Import Project

  1. Go to Vercel Dashboard.
  2. Select Import Git Repository and choose the pactum repository.
  3. Keep the default Root Directory (./).
  4. Framework Preset should auto-detect Web Application.
  5. Click Deploy.

2. Configure Environment Variables

Add the following environment variables in Vercel → Project → Settings → Environment Variables:

VariableRequiredDescription
NEXT_PUBLIC_SUPABASE_URLYesDatabase project URL
NEXT_PUBLIC_SUPABASE_ANON_KEYYesDatabase public (anon) key
PACTUM_CONTRACT_ADDRESSYesPactumBilling contract address
NEXT_PUBLIC_PACTUM_CONTRACT_ADDRESSYesSame contract address (client-side)
ARC_TESTNET_RPC_URLNoArc Testnet RPC (defaults to public RPC)

[!CAUTION] Ensure that your internal production secrets (such as Database Service Keys and Operator Wallet Keys) are set as Sensitive environment variables in Vercel (hidden after save).

3. Redeploy

After setting environment variables, trigger a redeployment:

  • Vercel → Project → Deployments → Redeploy (latest deployment)

Automated Settlement (Cron Job)

To run settlement automatically, create a vercel.json file in the project root:

{
  "crons": [
    {
      "path": "/api/v1/settlement/cron",
      "schedule": "0 0 * * *"
    }
  ]
}

This runs the settlement endpoint daily at midnight UTC.

[!NOTE] Vercel Cron Jobs automatically include the CRON_SECRET as the authorization header when configured. Alternatively, the settlement cron endpoint validates Authorization: Bearer <CRON_SECRET>.

Custom Schedules

ScheduleCron Expression
Every hour0 * * * *
Every 6 hours0 */6 * * *
Daily at midnight UTC0 0 * * *
Weekly (Sunday midnight)0 0 * * 0

Build Configuration

The project uses the following build settings (auto-detected by Vercel):

SettingValue
FrameworkWeb Application
Build Commandnpm run build
Output Directory.next
Install Commandnpm install
Node.js Version18.x

TypeScript Configuration

The tsconfig.json excludes test_integration/ and node_modules/ to prevent build errors from the separate Aura AI demo project:

{
  "exclude": ["node_modules", "test_integration"]
}

Post-Deployment Verification

After deployment, verify the following:

  1. Dashboard loads — Visit your Vercel domain and check that the login page renders.
  2. API responds — Test the usage tracking endpoint:
    curl -X POST https://your-domain.vercel.app/api/v1/usage/track \
      -H "Content-Type: application/json" \
      -H "X-API-Key: your_api_key" \
      -d '{"model":"test","user_address":"0x...","idempotency_key":"deploy-test-1"}'
    
  3. Database connection — Login and check that the dashboard loads usage data from Database.
  4. Settlement — Manually trigger a settlement and verify the on-chain transaction on Arc Explorer.

Troubleshooting

IssueCauseSolution
Build fails with TypeScript errorstest_integration/ included in buildEnsure tsconfig.json excludes test_integration
500 errors on API routesMissing environment variablesCheck all required env vars are set in Vercel
Settlement failsMissing operator configurationEnsure operator keys and PACTUM_CONTRACT_ADDRESS are set in Vercel
Dashboard shows no dataMissing database configurationEnsure internal database service keys are properly configured
CORS errors from external appsDefault Web Application CORS policyAdd appropriate CORS headers if needed