DEV Community

flat cash
flat cash

Posted on • Originally published at flat.cash

Add Private Payments to Your AI Agent Loop in 5 Minutes

You've built the loop. Your agent runs autonomously — researching, deciding, acting. But the moment it needs to pay for something, you hit a wall:

  • Every on-chain transaction is public (competitors see your strategy)
  • Wallets require seed phrases (agents can't manage those safely)
  • Payment APIs require KYC (agents don't have IDs)

Here's how to solve all three in 5 minutes.

The Problem: Transparent Transactions Kill Agent Autonomy

When your agent pays a data provider, the entire world sees:

  • Who paid whom
  • How much
  • When
  • The token used

That's not just a privacy problem. It's a competitive intelligence leak. If your trading agent pays for alpha, competitors can front-run you by watching your transactions.

The Solution: BearerSwap

BearerSwap is a commit-reveal protocol on Ethereum that breaks the on-chain link between sender and recipient.

npm install @flatcash/bearerswap ethers
Enter fullscreen mode Exit fullscreen mode
import { BearerSwap } from '@flatcash/bearerswap';

const bs = new BearerSwap({
  privateKey: process.env.AGENT_WALLET_KEY,
  rpcUrl: 'https://eth.drpc.org',
});

// Agent pays data provider privately
const { secret, nonce } = await bs.commit(
  FLAT_TOKEN, '10.0', dataProviderAddress
);

// Share secret off-chain (API call, encrypted message, etc.)
await fetch(providerAPI + '/payment', {
  method: 'POST',
  body: JSON.stringify({ secret, nonce })
});

// Provider claims tokens (arrives in 2-45 min with privacy delay)
Enter fullscreen mode Exit fullscreen mode

That's it. Three function calls. No KYC. No seed phrase management. No public transaction trail.

How It Works Under the Hood

Agent → commit(hash, token, amount) → Smart Contract
         ↓ (off-chain: share secret)
Provider → deliver(secret, address, nonce) → Relayer
         ↓ (random 2-45 min delay)
Relayer → reveal() → Contract → tokens arrive
Enter fullscreen mode Exit fullscreen mode

Privacy guarantees:

  1. The commit contains only a hash — no recipient info on-chain
  2. Random delay (exponential distribution, 2-45 min) breaks timing correlation
  3. Recipient also gets 0.0004 ETH gas stipend
  4. Zero protocol fees

Real Use Cases in Agent Loops

1. Pay-per-query data access

// In your agent's research loop:
async function buyData(query: string) {
  const { secret, nonce } = await bs.commit(FLAT, '1.0', dataVendor);
  const data = await fetch(vendorAPI, {
    headers: { 'X-Payment-Secret': secret, 'X-Payment-Nonce': nonce },
    body: JSON.stringify({ query })
  });
  return data.json();
}
Enter fullscreen mode Exit fullscreen mode

2. Agent-to-agent service payments

// Your orchestrator pays specialist agents
for (const task of completedTasks) {
  const { secret, nonce } = await bs.commit(FLAT, task.bounty, task.agentAddress);
  await notifyAgent(task.agentId, { secret, nonce });
}
Enter fullscreen mode Exit fullscreen mode

3. Anonymous content tipping

// Tip a creator without linking your identity
const { secret, nonce } = await bs.commit(FLAT, '5.0', creatorAddress);
await postComment(articleId, `Tipped! Claim: flat.cash/bearer?s=${secret}&n=${nonce}`);
Enter fullscreen mode Exit fullscreen mode

Why This Beats Alternatives

Feature BearerSwap Direct Transfer Tornado Cash Payment APIs
Privacy ✅ Full ❌ Public ✅ Full ❌ KYC required
Agent-friendly ✅ No KYC ❌ Sanctioned ❌ Human verification
Cost Free (gas only) Gas only High Fees
Speed 2-45 min Instant Hours Instant
Permissionless

Get Started

  1. Install: npm install @flatcash/bearerswap ethers
  2. Get FLAT tokens: flat.cash/buy-flat
  3. Read the docs: flat.cash/agents/docs
  4. Try the UI: flat.cash/bearer

Contract: 0x5de315Dab49012c5bbeC41d7a3B25c6829a3e566 (Ethereum Mainnet)


Built by the FLAT Protocol team. Zero fees. Zero KYC. Zero compromises on privacy.

If you're building agent loops that need financial primitives, check out the full MCP integration — your agent can earn, spend, and transact without ever needing a human.

Top comments (0)