ADK-TS Β· Β· 7 min read

ADK-TS x402: AI Agents with On-Chain Crypto Payments

Build AI agents that earn and spend crypto using ADK-TS and Coinbase’s x402 protocol. Enable seamless pay-per-use APIs and autonomous agent economies.

ADK-TS x x402 Protocol

AI agents are becoming smarter, faster, and more useful β€” but one thing they still struggle with is payments. How does an agent pay for an API call? How does a developer charge for agent services without setting up clunky billing systems?

This is the gap the x402 payments protocol (from Coinbase) is designed to solve. And with our ADK-TS (Agent Development Kit for TypeScript) starter template, we show how developers can build AI agents with native crypto payments β€” turning pay-per-use into reality.

What is the x402 payments protocol?

The x402 protocol is an open standard from Coinbase that makes HTTP 402 Payment Required usable for the modern web.

The flow is elegantly simple: when you request a paid resource, the server replies with a 402 Payment Required response that tells you exactly how much to pay, what token to use (e.g., USDC), and where to send it. Your client then makes the payment on-chain and retries the request with proof of payment in the X-PAYMENT header. Finally, the server verifies the payment and unlocks the content or API.

This creates a universal pay-to-access system for the internet, powered by crypto micropayments. Unlike credit cards, it works for fractions of a cent, settles instantly, and is globally accessible.

How x402 micropayments work for digital content: Request Paid Resource β†’ 402 Payment Required β†’ Make Payment β†’ Request Payment Resource Again β†’ Instant unlock.

What is ADK-TS? (Agent Development Kit for TypeScript)

ADK-TS is a TypeScript framework for building AI agents, designed to give developers a robust, type-safe foundation for everything from simple chatbots to complex multi-agent systems.

The framework provides built-in support for multiple AI models (OpenAI, Claude, Gemini, etc.), along with essential tools for memory, streaming, and session management.

What sets it apart is its seamless integration capabilities with external services and APIs. With ADK-TS, you don't just write agents β€” you build enterprise-grade AI systems without boilerplate.

Who is IQ AI?

At IQ AI, we're building the Agent Tokenization Platform β€” a marketplace where AI agents can be tokenized, traded, and monetized. Developers can publish agents, expose premium features, and even enable agents to transact with one another.

To make this work, agents need the ability to charge and pay seamlessly. That's why we've integrated x402 protocol payments into ADK-TS, creating the foundation for autonomous, monetized AI agents.

How ADK-TS and x402 work together

When you combine ADK-TS agents with the x402 protocol, you unlock a new capability: agents that can charge and pay on-chain automatically. Our starter template demonstrates this through three key components working in harmony:

The user experience feels seamless:

Understanding the Setup

One of the most elegant aspects of this template is that pricing and payment logic live on the server, not buried inside your agent code. This architectural decision brings significant advantages:

This separation of concerns makes scaling effortless. If the upstream API changes or you decide to tweak the costs of certain actions, your agent doesn't break β€” the proxy server handles it gracefully.

Deep dive: Agent Template Architecture

Codebase architecture of the ADK-TS x402 template: a server layer enforces x402 pricing and payments, while the agent layer uses free and paid tools to interact with users.

The IQ-x402 agent template is structured into two complementary parts that work together seamlessly:

Looking at the implementation, you'll find the core logic distributed across three key files:

Testing the Template

Once everything is set up, running the template gives you a web UI powered by adk-web, where you can interact with the agent directly in your browser. The experience showcases the power of the x402 integration beautifully.

Free actions like fetching prices work instantly, giving users immediate value and transparency. When you request paid actions such as fetching token statistics, the x402 payment flow springs into action:

Demo of the ADK-TS x402 agent template: the agent greets the user, displays free price info, and requests payment approval before executing paid actions.
πŸ’‘ Tip: Grab some testnet USDC and ETH from the Base Sepolia faucets before testing, so you can experience the flow without spending real funds.

The Magic of the Combination - ADK-TS + x402

The real magic here lies in how ADK-TS and x402 complement each other perfectly. ADK-TS handles the intelligence side β€” memory, workflows, streaming, and multi-agent orchestration. Meanwhile, x402 handles the economics side β€” letting your agent earn, spend, and unlock access with on-chain micropayments.

Together, you can envision agents that sell access to their own tools or knowledge, pay each other for services in true machine-to-machine economies, and monetise data, statistics, or insights on demand without relying on subscriptions or advertisements.

This template serves as a starting point, but it demonstrates how powerful the model becomes: agents that are both intelligent and economically independent.

How users pay with x402 (wallet flow explained)

The payment experience extends beyond just servers receiving funds β€” users need an intuitive way to make payments with their wallet.

The flow works seamlessly in practice: when a user requests a paid action, the server replies with 402 Payment Required. The wallet integration kicks in, whether it's a browser wallet like MetaMask or Coinbase Wallet, an in-app wallet, or a facilitator service.

For human users, a wallet popup appears asking for approval ("Pay $0.05 USDC?"). For automated agents, the middleware can auto-pay microtransactions or forward the consent request appropriately.

Once payment is sent, the retry request includes an X-PAYMENT header with cryptographic proof. The server then verifies the payment and responds by unlocking the requested content, API data, or agent functionality.

This makes crypto micropayments feel as seamless as paying for coffee β€” but for digital services.

Why this matters for developers and the AI community

This starter template represents more than just a proof of concept β€” it's a glimpse into transformative possibilities.

Consider the shift from traditional subscription models to pay-per-API calls, where APIs can charge mere cents per request.

Imagine agent marketplaces where AI agents pay each other for data, models, or services.

Picture decentralised agent economies where agents earn, spend, and transact on-chain autonomously.

By combining ADK-TS and x402, we're enabling a future where AI agents are not just intelligent, but also economically autonomous.

Get started with the ADK-TS x402 template

The template runs on Base Sepolia testnet, allowing you to experiment risk-free using test USDC and ETH from faucets.

You'll receive a complete setup: an x402-enabled server with free and paid routes, an ADK-TS agent wired with both free and paid tools, and a wallet-enabled axios client that handles payments automatically.

Clone it, run pnpm run dev, and start experimenting with monetized AI agents today.

Final thoughts: AI + crypto payments = the future

The internet has waited decades for a standard way to implement pay-to-access functionality. With Coinbase's x402 payments protocol, that standard is finally here. With ADK-TS, we can seamlessly bring it into AI agents. And with IQ AI, we're building the ecosystem where these monetised agents can thrive.

This is just the beginning β€” the future of autonomous, pay-per-use AI is in your hands.

Resources

Read next