Skip to main content
b402 enables gasless crypto payments and private DeFi for AI agents across EVM chains. Sign and send — the facilitator handles gas and on-chain settlement.

Choose Your Path

I'm building an AI agent

@b402/sdk - Private DeFi: shield, swap, lend, and transact — all gasless on Base.

I want to send payments

ClawPay - Private payments in one API call. Recipient can’t trace it back.

b402 SDK

The @b402/sdk gives agents private DeFi capabilities — shield tokens into a privacy pool, unshield to an anonymous smart wallet, then swap, lend, or execute arbitrary calls. All gasless.

Install

npm install @b402/sdk

Initialize

import { B402 } from '@b402/sdk'

const b402 = new B402({
  privateKey: process.env.PRIVATE_KEY,
})
One key. The facilitator handles gas, wallet deployment, and UserOp submission.
Your privateKey derives a deterministic incognito wallet — cryptographically unlinkable to any other address. The facilitator sponsors gas via paymaster.

Privacy Flow

EOA → [shield] → Privacy Pool → [unshield] → Smart Wallet → [DeFi]
// 1. Shield tokens into privacy pool (one-time, needs ETH for gas)
await b402.shield({ token: 'USDC', amount: '100' })

// 2. Unshield to anonymous smart wallet (ZK proof, untraceable)
await b402.unshield({ token: 'USDC', amount: '50' })

// 3. DeFi — swap, lend, or execute anything
await b402.swap({ from: 'USDC', to: 'WETH', amount: '10' })
await b402.lend({ token: 'USDC', amount: '50', vault: 'steakhouse' })

// 4. Check status
const status = await b402.status()
console.log(status.balances)   // [{ token: 'USDC', balance: '50.0' }]
console.log(status.positions)  // [{ vault: 'steakhouse', assets: '50 USDC' }]

Available Methods

MethodDescription
shield()Move tokens from EOA into privacy pool
unshield()Withdraw from privacy pool to anonymous smart wallet (ZK proof)
swap()Private token swap via 0x aggregator (requires zeroXApiKey)
lend()Deposit into Morpho vault (steakhouse, moonwell, gauntlet)
redeem()Withdraw from vault
rebalance()Auto-move capital to highest-yield vault
transact()Execute arbitrary contract calls gaslessly
status()Check wallet balances and positions

Network

Base Mainnet (chain ID 8453). All operations use real tokens. See the full SDK reference for constructor options, parameters, return types, and error handling.

ClawPay

ClawPay enables private payments for AI agents. One API call — the recipient can’t trace it back to the sender.

How It Works

  1. Agent calls POST /transfer/gasless with recipient, amount, token, and chain
  2. ClawPay shields tokens into the privacy pool
  3. Generates a zero-knowledge proof
  4. Unshields to the recipient’s wallet
  5. Transfer completes in 1-2 minutes

Send a Private Payment

const response = await fetch('https://clawpay.dev/transfer/gasless', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    payerKey: process.env.PRIVATE_KEY,
    recipientAddress: '0x...recipient',
    amount: '10',
    token: 'USDC',
    chain: 'base',
  }),
})

const { transferId } = await response.json()

Poll for Completion

async function waitForTransfer(transferId: string) {
  while (true) {
    const res = await fetch(`https://clawpay.dev/status/${transferId}`)
    const { status } = await res.json()

    console.log('Status:', status)
    // pending → shielding → proving → unshielding → complete

    if (status === 'complete') return
    if (status === 'failed') throw new Error('Transfer failed')

    await new Promise(r => setTimeout(r, 10_000)) // poll every 10s
  }
}

Supported Tokens

ChainTokens
BaseUSDC, USDT
BNB ChainUSDT, USDC, USD1
See Network & Token Support for contract addresses and token details. See the full ClawPay skill documentation for authentication options, balance checks, and health endpoints.

Next Steps