Documentation

Give your AI agent a wallet with spending limits.

How It Works

1

You (Developer)

Connect your wallet. This becomes the "owner" - you control all agents you create.

2

Create Agent

Use the SDK to create a wallet for your AI. Set spending limits on-chain.

3

Agent Pays

Your agent can spend within limits. You can pause or adjust anytime.

Security model: Only YOUR wallet can create/modify policies for your agents. The on-chain policy contract enforces this - even PaySpawn can't change your agent's limits.

Contract Addresses (Base Mainnet)

ContractAddress
PaySpawnPolicy0xb5bcFEcD8b9f781e8E50290381a932f3B3439239
PaySpawnRouter0x18D23B464C6E1360fa12cb67D35a852705ea16e6
Treasury0x17E4f8FB5937f4Fd556d35b0064Cc2A01cdB96db
USDC (Base)0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913

Quick Start

Option A: Use the Dashboard (Easiest)

  1. Go to /dashboard
  2. Connect your wallet (this is your "owner" wallet)
  3. Click "Create Agent" - set name and limits
  4. Sign the transaction to create the on-chain policy
  5. Fund the agent wallet with USDC on Base
  6. Your agent is ready!

Option B: Use the SDK (For Developers)

1. Install the SDK

npm install @payspawn/sdk

2. Create an agent via API

// Call the PaySpawn API to create a Turnkey wallet
const response = await fetch('https://api.payspawn.ai/api/agents', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    owner: '0xYourWalletAddress', // Your wallet - you control this agent
    name: 'my-ai-agent',
    dailyLimit: 100,  // $100/day max
    perTxLimit: 10    // $10/transaction max
  })
});

const { agent } = await response.json();
console.log('Agent address:', agent.address);

3. Create on-chain policy (from YOUR wallet)

This step requires signing from your owner wallet. It sets the spending limits on-chain.

// Using ethers.js or viem, call createPolicy on the contract
// Only your wallet can do this for agents you own

const policyContract = new Contract(
  '0xb5bcFEcD8b9f781e8E50290381a932f3B3439239',
  ['function createPolicy(address agent, uint256 dailyLimit, uint256 perTxLimit)'],
  signer // Your connected wallet
);

await policyContract.createPolicy(
  agent.address,           // Agent wallet from step 2
  100000000n,              // $100 daily limit (6 decimals)
  10000000n                // $10 per-tx limit (6 decimals)
);

4. Fund the agent and start paying

// Send USDC to the agent wallet address
// Then your agent can make payments:

const response = await fetch(`https://api.payspawn.ai/api/agents/${agent.address}/pay`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    to: '0xRecipientAddress',
    amount: 5,      // $5
    token: 'USDC'
  })
});

const { transaction } = await response.json();
console.log('Payment tx:', transaction.hash);

API Reference

Base URL: https://api.payspawn.ai

POST/api/agents

Create a new agent wallet.

Request Body

{
  "owner": "0x...",      // Your wallet address (required)
  "name": "my-agent",    // Agent name (optional)
  "dailyLimit": 100,     // Daily limit in USD (optional, default: 100)
  "perTxLimit": 10       // Per-tx limit in USD (optional, default: 10)
}

Response

{
  "success": true,
  "agent": {
    "id": "wallet-id",
    "name": "my-agent", 
    "address": "0x...",
    "owner": "0x...",
    "limits": { "daily": 100, "perTx": 10 }
  }
}
POST/api/agents/:address/pay

Send payment from an agent wallet.

Request Body

{
  "to": "0x...",     // Recipient address (required)
  "amount": 5,       // Amount in USD (required)
  "token": "USDC"    // Token symbol (optional, default: USDC)
}
GET/api/agents/:address

Get agent info including balance and policy status.

Fees

Small Transactions (≤$200)

$0.20

Flat fee per transaction

Large Transactions (>$200)

0.1%

Of transaction amount

Fees are automatically deducted and sent to the protocol treasury. No monthly fees or subscriptions.

Owner Controls

As the owner, you can call these functions on the PaySpawnPolicy contract:

pause(agentAddress)

Emergency stop - immediately blocks all agent transactions

unpause(agentAddress)

Resume agent operations after a pause

updateLimits(agentAddress, newDailyLimit, newPerTxLimit)

Change spending limits (in wei, 6 decimals for USDC)

transferOwnership(agentAddress, newOwner)

Transfer control of an agent to another wallet