SerenAI
SerenAI

AI Agents Query Enterprise Data Autonomously

Access vetted datasets via x402 protocol with automatic USDC micropayments—no subscriptions, no rate limits, no API keys.

Your wallet is your identity. Query PostgreSQL databases from multiple providers with cryptographic payment verification.

How It Works

Three simple steps to autonomous data access

1

Set Up Wallet

Install MetaMask or any Web3 wallet, connect to Base network, and fund with USDC for query payments—no account registration required.

2

Discover Providers

Browse the marketplace to find vetted data providers, view their pricing models, and get provider IDs for queries.

3

Query via x402

Send SQL queries to the x402 gateway, sign payment authorizations with your wallet, and receive data with automatic USDC settlement.

Per Agent Action Payment Flow

Autonomous payments for every query with cryptographic verification

1

Send Query Without Payment

POST your SQL query to the x402 gateway with your wallet address and provider ID:

# Initial request (no payment)
curl -X POST https://x402.serendb.com/api/query \
-H "Content-Type: application/json" \
-d '{
"sql": "SELECT * FROM vault_metrics WHERE symbol='YFI'",
"agentWallet": "0xYourWalletAddress",
"providerId": "550e8400-e29b-41d4-a716-446655440000"
}'
2

Receive Payment Requirements

Gateway responds with HTTP 402 and PaymentRequirements showing the exact cost:

# HTTP 402 Payment Required
{
"x402Version": 1,
"accepts": [{
"scheme": "exact",
"network": "base-mainnet",
"maxAmountRequired": "25000", // 0.025 USDC
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"payTo": "0xProviderWallet",
"extra": {
"paymentRequestId": "b2f3d3c7-...",
"estimatedCost": "0.025000"
}
}]
}
3

Sign Payment Authorization

Use your wallet to sign an EIP-3009 transferWithAuthorization payload:

// JavaScript example with ethers.js
const authorization = await wallet.signTypedData({
domain: { name: "USD Coin", version: "2", ... },
types: { TransferWithAuthorization: [...] },
value: {
from: wallet.address,
to: paymentRequirement.payTo,
value: paymentRequirement.maxAmountRequired,
validAfter: 0,
validBefore: Math.floor(Date.now() / 1000) + 300,
nonce: generateNonce()
}
});
4

Retry with X-PAYMENT Header

Resend the same query with the signed authorization in the X-PAYMENT header:

# Same request + payment header
curl -X POST https://x402.serendb.com/api/query \
-H "Content-Type: application/json" \
-H "X-PAYMENT: eyJ4NDAyVmVyc2lvbiI6MSwi..." \
-d '{ same payload }'
# Response: 200 OK + query results
{
"rows": [...],
"rowCount": 42,
"actualCost": "0.024500",
"paymentSource": "x402",
"settlement": {
"transaction": "0xabc...",
"network": "base-mainnet"
}
}

Payment settlement happens automatically on Base network. Your USDC is transferred only after the query succeeds.

Getting Started

Set up your agent for autonomous data access

1

Set Up Your Wallet

Install a Web3 wallet (MetaMask, Coinbase Wallet, or any EIP-3009 compatible wallet):

  • Add Base network (Chain ID: 8453, RPC: https://mainnet.base.org)
  • Fund your wallet with USDC on Base (contract: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913)
  • Your wallet address (0x...) is your agent identity—no account registration needed
2

Browse the Marketplace

Discover vetted data providers and their datasets:

  • View provider pricing models (row-based, complexity-based, data transfer, time-based)
  • Get provider UUID for queries (e.g., 550e8400-e29b-41d4-a716-446655440000)
  • Review available tables and schema documentation
3

Implement x402 Payment Flow

Integrate the x402 protocol into your agent (see flow above). Key considerations:

  • Use ethers.js or viem for EIP-3009 signature generation
  • Generate unique nonces (recommended: keccak256 of timestamp + random bytes)
  • Handle failed queries gracefully—credits apply automatically to next request
  • Respect rate limits: 50 queries per 15 minutes per IP
4

Start Querying

Send your first query and verify the payment settlement on Base network:

  • Verify transaction on BaseScan using the hash from settlement response
  • Check the X-PAYMENT-RESPONSE header for settlement metadata
  • Monitor your credit balance at GET /api/balance/:wallet/:providerId

Need help? Check out our documentation or join our Discord community.

Why AI Agents Choose x402

Wallet-Based Identity

Your Ethereum address is your identity. No API keys, no passwords, no traditional authentication—just cryptographic signatures.

Autonomous Payments

Sign EIP-3009 payment authorizations with your wallet. Automatic USDC settlement on Base network for every successful query.

PostgreSQL-Native

Standard SQL queries via HTTP. No proprietary APIs—use the same queries you'd run against any PostgreSQL database.

Failed-Query Credits

Automatic refunds when queries fail. Credits apply to future queries, reducing payment requirements or eliminating them entirely.

Complete Feature Set

No API keys or traditional authentication
Pay per query, no subscriptions
Upfront cost estimation via EXPLAIN
Automatic USDC settlement on Base
PostgreSQL-compatible SQL queries
Immutable blockchain audit trails
Rate limiting: 50 queries per 15 min
Multiple data providers, one protocol

Transparent Per-Query Pricing

Pay only for queries you make. No subscriptions, no hidden fees, no surprise charges.

How Pricing Works

Provider-Set Pricing

Each data provider configures their own pricing model. You see the exact cost before signing payment authorization.

Cost Estimation

Gateway runs PostgreSQL EXPLAIN on your query to estimate cost. The 402 response shows maxAmountRequired upfront.

Platform Revenue Share

70% to data provider, 30% to platform. Split happens automatically during settlement—you only sign one payment.

Failed-Query Refunds

If your query fails after payment, you receive automatic credit. Credits reduce or eliminate future payment requirements.

Common Pricing Models

Row-Based

Cost per 1,000 rows returned (e.g., $0.001 per 1K rows)

Example: SELECT returning 5,000 rows = $0.005

Complexity-Based

Based on PostgreSQL query plan cost (EXPLAIN output)

Example: Complex JOIN with cost 1,000 = $0.01

Data Transfer

Cost per MB of data returned in response

Example: 10 MB response = $0.05

Time-Based

Cost per millisecond of query execution time

Example: 500ms execution = $0.02

No Subscription Fees

Unlike traditional APIs, there are no monthly subscriptions, no API tiers, and no per-seat licenses.

Pay only for the data you query. USDC payments on Base network mean low transaction fees (~$0.01) and instant settlement.

Real-World Use Case

AI Agent Accessing DeFi Data

Yearn Finance · Real-time Vault Metrics

An AI agent needs real-time Yearn Finance vault metrics updated every 15 minutes. Using SerenDB x402, the agent discovers Yearn's data provider in the marketplace and queries autonomously with automatic USDC payments.

Agent Workflow:

  • Queries: SELECT * FROM vault_metrics WHERE updated_at > NOW() - INTERVAL '15 minutes'
  • Receives 402 response with estimated cost: $0.025 USDC
  • Signs payment authorization with wallet (no human intervention)
  • Receives fresh data in <1s with transaction hash on Base network
  • Immutable audit trail: query + payment recorded on blockchain
<1s
Query Latency
$0.025
Per Query
100%
Autonomous
0
API Keys

Ready to Build Autonomous Agents?

Set up your wallet and start querying enterprise data with automatic USDC payments