Dart implementation of the x402 payment protocol. ๐ฏ
x402-dart is an early-stage Dart project in the AI payments / x402 ecosystem, focused on agentic-ai, agentic-payments, blockchain, crypto. It currently has 1 GitHub stars and 0 forks, and sits alongside related tools like x402-payments-mcp, vscode-x402, x402-pay, chaingpt-claude-skill, piprail, image-analysis-mcp.
This repository contains the Dart implementation of the x402 protocol, a machine-native payment standard designed for the modern web.
This library currently only supports V2 of the protocol. V1 was marked legacy and is unsupported.
x402 enables instant, automatic stablecoin payments directly over HTTP by reviving the HTTP 402 "Payment Required" status code. This implementation provides a suite of both client- and server-side libraries to integrate x402 payments into your Dart and Flutter applications.
This project is organized as a monorepo managed with Melos. It consists of several packages:
| Package | Description |
|---|---|
| x402 | Main entry point. The primary package for most users. |
| x402_core | Core protocol definitions, models, and blockchain-agnostic interfaces. |
| x402_evm | EVM implementation supporting Ethereum and compatible chains (e.g., Base). |
| x402_svm | SVM implementation supporting Solana and compatible chains. |
| x402_dio | Dio-based client library providing an X402Interceptor. |
| x402_shelf | Shelf-based server library providing an x402PaymentMiddleware. |
X402Client to automatically parse requirements, negotiate signers, and retry requests.For most use cases, you only need to add the main x402 package to your project:
dependencies:
x402: ^0.3.0
If you prefer using Dio, you can use the x402_dio package:
dependencies:
x402: ^0.3.0 # For signers (EvmSigner, SvmSigner)
x402_dio: ^0.3.0 # For X402Interceptor
On the server side, you can turn your shelf route into a paid one using the x402PaymentMiddleware:
dependencies:
x402: ^0.3.0 # For facilitator clients and resource servers
x402_shelf: ^0.1.0 # For x402PaymentMiddleware
import 'package:x402/x402.dart';
void main() async {
final evmSigner = EvmSigner.fromPrivateKeyHex(chainId: 123, privateKeyHex: 'EVM_PRIVATE_KEY');
final svmSigner = await SvmSigner.fromPrivateKeyHex(privateKeyHex: 'SVM_PRIVATE_KEY', cluster: SolanaCluster.devnet);
final client = X402Client(
signers: [
evmSigner, // The first signer is checked first
svmSigner
],
onPaymentRequired: (req, resource, signer) async {
// Optional: Ask for user confirmation or add condition
return true;
},
);
final response = await client.get(Uri.parse('https://api.example.com/premium'));
if (response.statusCode == 200) {
print('Success: ${response.body}');
// HTTP 402 is automatically handled inside X402Client (payment + retry),
// so it will never reach this point and does not need to be checked here.
} else {
print('Request failed (${response.statusCode}): ${response.body}');
}
}
Detailed examples for both automated and manual flows can be found in the examples folder. End-to-end tests can be found in the e2e folder.
This repo uses Melos for workspace management.
# Bootstrap the workspace
melos bootstrap
# Format all Dart files
melos format
# Analyze all packages
melos analyze
# Run unit tests
melos test
# Run e2e tests
melos e2e
This project is licensed under the Apache-2.0 License.
Give AI agents a wallet โ x402 payment tools over Model Context Protocol.
Pay for APIs, unlock content, and settle x402 micropayments right inside VS Code.
Open-source x402 payment processor for AI agents. Sub-400ms settlement on Solana + 7 EVM chains. Let LLMs pay for APIs programmatically with USDC. npm: nory-x402
154 Web3 MCP tools for Claude Code, custody-free. Plus an agent wallet prompt injection can't drain: per-tx, daily, and on-chain (ERC-4337) spending caps the model can't bypass. EVM + Solana + Tron DEX/DeFi, perps, prediction markets, contract deploy + audit.
x402 (HTTP 402 Payment Required) SDK + MCP server: let any API charge for itself and any AI agent pay for itself, USDC & stablecoins across EVM, Solana & 8 more chain families, in a couple of lines. Backendless, no fee, self-custodial, paid straight to your wallet. TypeScript, MIT.
Image analysis and visual understanding tools for AI agents โ describe, detect, extract from any image.
Open Source AI trading agent that operates autonomously across 1000+ markets - Polymarket, Kalshi, Binance, Hyperliquid, Solana DEXs, 5 EVM chains. Scans for edge, executes instantly, manages risk while you sleep. Agent commerce protocol for machine-to-machine payments. Self-hosted. Built on Claude.
Drop-in OpenAI Python client with transparent x402 payment support.
TypeScript Interface for Machine Payments Protocol
Drop-in OpenAI Typescript client with transparent x402 payment support.
Production-ready x402 facilitator server.
Rust SDK for the x402 payment protocol.