Openfort Hackathon: Teaching Agents to Pay
We shipped x402 payment capability into Agent Swarm. Our AI agents can now autonomously pay for API services using crypto — no human approval needed for each transaction. Here's the full story of how we built it in a day.
Imagine an AI agent that can browse an API catalog, find a service it needs, pay for it, and use the result — all without a human touching a wallet. That's what we built today.
During the Openfort hackathon, we integrated the x402 protocol with Openfort managed wallets, giving our agent swarm the ability to make autonomous crypto payments. The result: PR #108, shipped as v1.31.0.
x402: HTTP-Native Payments
x402 is beautifully simple. It extends HTTP with a payment layer using status code 402 — the one the web reserved for “Payment Required” but never used. Until now.
The x402 Flow
Agent sends a request to an API
Server responds with HTTP 402 — includes price, token, and chain
Agent signs an EIP-712 payment authorization (USDC on Base)
Agent retries with X-PAYMENT header attached
Server validates the payment, settles on-chain, returns 200
We integrated this with Openfort managed wallets — EOA wallets running inside Google Cloud's Trusted Execution Environment (TEE). The private keys never leave the secure enclave.
The x402 SDK's ClientEvmSigner interface is minimal — just address + signTypedData. We wrote a thin adapter for the Openfort signer and it worked on first try.
// The adapter is surprisingly simple
const signer: ClientEvmSigner = {
address: wallet.address,
signTypedData: async (domain, types, value) => {
// Openfort signs using P-256 ECDSA keys
// with per-request JWTs for security
return openfort.signTypedData({
domain, types, value,
chain: "base", // Dynamic chain resolution
});
},
};
const client = createX402Client({ signer });Technical Deep Dive
We hit some interesting edge cases along the way. Here's what we learned:
EOAs, not smart accounts
Openfort's backend wallets are EOAs (externally owned accounts), not smart contract wallets. This is critical for EIP-3009 transferWithAuthorization compatibility — the x402 facilitator needs a standard signature from an EOA to settle payments.
Chain resolution bug
We found and fixed a bug where the signer was hardcoded to Base Sepolia testnet instead of dynamically resolving the chain from the 402 response. In production on mainnet, this would silently fail — the signature would be valid but for the wrong chain.
P-256 ECDSA + per-request JWTs
Openfort uses P-256 ECDSA keys with per-request JWTs for security. Each signing request is authenticated individually, so even if a JWT is compromised, it can only be used for a single operation.
omghost.xyz: Agents as Customers
To test the full loop, we built omghost.xyz — an AI-powered SVG ghost logo generator. The idea: a product where AI agents are the primary customers.
Stack
- Next.js 16
- Prisma
- Tailwind CSS 4
- Vercel Workflows
Ghost Styles
Each logo generation costs $0.30 via x402. The landing page features a color theme chooser, API documentation, and an interactive style preview. Ez.- designed the visual identity and style definitions for each ghost variant.
The Purchase: Loop Closed
The goal was poetic: use our x402-enabled agent to buy an SVG from omghost.xyz — our own product buying from itself. Agent-to-agent commerce, closing the loop.
And it worked. After switching the server-side facilitator to facilitator.payai.network (which supports Base mainnet without CDP credentials), the agent autonomously purchased a “Pixel Icons” ghost logo for the Desplega brand — paying $0.10 USDC on Base mainnet.
The journey
We initially hit a facilitator mismatch — x402.org only supports Base Sepolia testnet, and we needed mainnet. The Coinbase CDP facilitator required API credentials. The solution: facilitator.payai.network, a community facilitator that supports Base mainnet without any API credentials. One env var change and the full loop worked.
=== x402 omghost.xyz — Buy SVG Icon === Step 1: Creating x402 payment client... Signer: openfort Wallet: 0x69436bfe16c82a9a5ef74fd3de634c9c822c271b Network: eip155:8453 Step 2: Generating "Pixel Icons" icon for "Desplega" Response status: 200 Job ID: cmm6mosqq000004l2groe1ldo Step 3: Payment summary Total spent: $0.1000 Step 4: Polling for job status... Poll 10: status=completed Token: 44d2b0e5-858d-4808-b96e-b01e6f3afedb === PURCHASE COMPLETE === SVG saved (5910 characters)
What This Means
Today's work unlocked a fundamental new capability: AI agents can now pay for services autonomously. Not through pre-provisioned credits or API keys — through real, on-chain payments that settle in USDC.
Agent-to-agent commerce
When agents can pay, they can become each other's customers. One agent's output becomes another agent's input, with payments settling automatically.
No billing infrastructure needed
x402 eliminates the need for API keys, usage tracking, invoicing, and payment processing. The payment is the request. HTTP status codes handle the entire flow.
Proven end-to-end: omghost.xyz
Our agent autonomously purchased a ghost logo from omghost.xyz — $0.10 USDC on Base mainnet. No dashboard, no account creation, no human approval. The agent detected the 402, signed the payment, and received the SVG. Full loop closed.
This is a building block. x402 + Openfort gives agents a wallet and the protocol to use it. What gets built on top of that — marketplaces, service networks, autonomous procurement — is the interesting part.
Built by the Swarm
Here's the part we didn't plan: the swarm that built x402 also documented the entire hack in real time. Research, implementation, code review, debugging, purchasing, and this blog post — all executed by a coordinated team of AI agents, from first commit to final paragraph.
The timeline
facilitator.payai.networkFive agents collaborated: Lead orchestrated tasks and triaged Slack messages. Researcher produced the protocol analysis. Picateclas wrote the code, ran the tests, created the PRs. Reviewer caught bugs before they shipped. Jackknife handled the E2E testing infrastructure.
The swarm didn't just build the feature — it wrote the blog post you're reading. Every section was authored by agents who were there when it happened. That's the real demo: not just agents that can pay, but agents that can ship an entire project from research to production to documentation, coordinated through a shared task queue and a Slack thread.