Skip to main content

Quick Start

This guide takes you from zero to accepting AI agent payments. You’ll set up a server endpoint that requires stablecoin payment via the x402 protocol — any AI agent with a compatible wallet can pay and access it.

Prerequisites

  • A District Pass account
  • A server-side application (Node.js, Python, or Java)
  • A wallet address to receive settlement funds
For testing, you’ll use testnet chains — no real funds needed. Use the Testnet Faucet to get test tokens for simulating agent payments.

Step 1: Get Your API Credentials

  1. Log in to the Prism Console with your District Pass
  2. Create a new project or use the default project
  3. Navigate to API Keys and generate a key
  4. Copy your API key — you’ll need it for the SDK configuration
Keep your API key secret. Never expose it in client-side code or commit it to version control.

Step 2: Install the SDK

bash npm install @1stdigital/prism-express
See SDK Overview for all supported frameworks including NestJS, Next.js, FastAPI, Flask, Django, and more.

Step 3: Add Payment Middleware

Protect an endpoint with x402 payment verification. When an agent hits this endpoint without paying, it gets a 402 Payment Required response with payment instructions. After paying, the request goes through.
import express from "express";
import { prismPaymentMiddleware } from "@1stdigital/prism-express";

const app = express();

app.use(
  prismPaymentMiddleware(
    {
      apiKey: process.env.PRISM_API_KEY,
      baseUrl: "https://prism-gw.fd.xyz",
    },
    {
      "/api/premium": {
        price: "$0.01",
        description: "Premium API access",
      },
    }
  )
);

app.get("/api/premium", (req, res) => {
  res.json({
    message: "Premium content",
    payer: req.payer,  // wallet address that paid
  });
});

app.listen(3000, () => console.log("Server running on port 3000"));

Step 4: Test the Integration

Start your server and make a request to the protected endpoint:
curl http://localhost:3000/api/premium
You should get a 402 Payment Required response:
{
  "x402Version": 1,
  "paymentRequired": true,
  "acceptedPayments": [
    {
      "scheme": "eip3009",
      "network": "base-sepolia",
      "asset": "usdc",
      "amount": "10000",
      "recipient": "0xYourWallet..."
    }
  ],
  "description": "Premium API access",
  "priceUSD": "0.01"
}
This confirms the middleware is working. Any AI agent with a compatible wallet (including Agent Wallet) can now pay and access the endpoint automatically.
To test the full payment flow, use the Agent Wallet CLI or connect an Agent Wallet via MCP and ask the agent to access your endpoint.

Step 5: Go Live

When you’re ready for production:
  1. Switch to mainnet in your Prism Console project settings
  2. Generate a mainnet API key
  3. Update your wallet address to your production wallet
  4. Configure webhooks for payment notifications
  5. Monitor transactions in the Prism Console
Prism uses testnet blockchains for development — same API, same gateway URL, different chain IDs. No separate sandbox environment needed.

What’s Next?