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
- Log in to the Prism Console with your District Pass
- Create a new project or use the default project
- Navigate to API Keys and generate a key
- 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
bash pip install finance-district
<dependency>
<groupId>xyz.financedistrict</groupId>
<artifactId>prism-sdk</artifactId>
<version>LATEST</version>
</dependency>
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"));
from fastapi import FastAPI, Depends
from finance_district import require_payment, PaymentVerified
app = FastAPI()
@app.get("/api/premium")
async def premium_content(
payment: PaymentVerified = Depends(require_payment(0.01, "USD"))
):
return {"content": "Premium data", "payer": payment.payer}
from flask import Flask, jsonify
from finance_district import require_payment
app = Flask(__name__)
@app.route("/api/premium")
@require_payment(amount=0.01, currency="USD")
def premium_content():
return jsonify({"content": "Premium data"})
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:
- Switch to mainnet in your Prism Console project settings
- Generate a mainnet API key
- Update your wallet address to your production wallet
- Configure webhooks for payment notifications
- 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?