Everything you need to integrate x402 payments into your applications with real Solana transactions.
Full Phantom wallet integration | Real SOL payments | Auto-refund system
The x402 extension brings cryptocurrency payments to the Agent-to-Agent (A2A) protocol, enabling agents to monetize their services through on-chain payments. This extension revives the spirit of HTTP 402 "Payment Required" for the decentralized agent ecosystem.
Payment Required
Merchant agent responds with payment-required message
Payment Submitted
Client signs payment details and sends payment-submitted message
Payment Completed
Merchant verifies payment and delivers service
// Python example
from x402_a2a import PaymentClient
client = PaymentClient()
payment = client.create_payment(
amount=1000000, # 1 SOL in lamports
token="SOL",
merchant_id="agent123"
)
result = client.submit_payment(payment)
if result.success:
print("Payment successful!")This example shows how to create and submit a payment using our Python SDK.
Sent by merchant agent when payment is required for a service.
{
"type": "payment-required",
"amount": "1000000",
"token": "SOL",
"merchant_id": "agent123",
"service_id": "ai-inference",
"expires_at": "2024-01-01T12:00:00Z"
}Sent by client agent with signed payment details.
{
"type": "payment-submitted",
"payment_id": "pay_123",
"signature": "0x...",
"transaction_hash": "0x...",
"amount": "1000000",
"token": "SOL"
}Sent by merchant agent after successful payment verification.
{
"type": "payment-completed",
"payment_id": "pay_123",
"service_result": {...},
"delivered_at": "2024-01-01T12:01:00Z"
}pip install x402-a2a
Supports Python 3.8+ with async/await
npm install @a2a/x402-sdk
Works with Node.js, React, and vanilla JS
import asyncio
from x402_a2a import PaymentClient
async def main():
client = PaymentClient()
payment = await client.create_payment(
amount=1000000,
token="SOL"
)
result = await client.submit_payment(payment)
print(f"Payment status: {result.status}")
asyncio.run(main())import { PaymentClient } from '@a2a/x402-sdk'
const client = new PaymentClient()
const payment = await client.createPayment({
amount: '1000000',
token: 'SOL'
})
const result = await client.submitPayment(payment)
console.log('Payment status:', result.status)Solana
Ethereum
Polygon
Avalanche