Getting Started

Set up your r1x development environment and start building on the machine economy.

Prerequisites

Before you begin, ensure you have:

  • Node.js 20.9.0 or higher
  • npm 10.0.0 or higher
  • A Base network wallet (MetaMask recommended)
  • USDC on Base mainnet for testing
  • A Coinbase Developer Platform account (for PayAI facilitator)

Environment Setup

Create a .env.local file in your project root with the following variables:

Environment Variables
DATABASE_URL="postgresql://..."
MERCHANT_ADDRESS="0x..."
FEE_RECIPIENT_ADDRESS="0x..."
PLATFORM_FEE_PERCENTAGE=5
NETWORK=base
ANTHROPIC_API_KEY="sk-ant-..."
CDP_API_KEY_ID="your-cdp-api-key-id"
CDP_API_KEY_SECRET="your-cdp-api-key-secret"
NEXT_PUBLIC_BASE_URL="http://localhost:3000"
FACILITATOR_URL="https://facilitator.payai.network"
PayAI Configuration
For Base mainnet, PayAI facilitator requires Coinbase Developer Platform (CDP) API keys for authentication. Get your keys from portal.cdp.coinbase.com and set them as CDP_API_KEY_ID and CDP_API_KEY_SECRET.

Database Setup

r1x uses Prisma with PostgreSQL. Set up your database:

Database Commands
# Generate Prisma client
npx prisma generate

# Run migrations (development)
npx prisma migrate dev

# Run migrations (production)
npx prisma migrate deploy

# Open Prisma Studio (optional)
npx prisma studio

Installation

Install dependencies and start the development server:

Installation
# Install dependencies
npm install

# Start development server
npm run dev

# Start x402 Express server (separate terminal)
npm run dev:x402

# Start both servers concurrently
npm run dev:all
Express Server
The x402 Express server runs separately on Railway and handles payment middleware. Configure NEXT_PUBLIC_X402_SERVER_URL to point to your Railway deployment.

Sync PayAI Services

After deployment, sync services from PayAI facilitator:

Sync Services
# Trigger PayAI service sync
curl -X POST https://your-domain.vercel.app/api/sync/payai

# Or with authentication (if SYNC_SECRET is set)
curl -X POST https://your-domain.vercel.app/api/sync/payai \
  -H "Authorization: Bearer YOUR_SYNC_SECRET"
Ready to Build
You're all set! Visit Utilities to learn about available tools and Tutorials for step-by-step guides.
server.r1xlabs.com