Skip to content

UltravioletaDAO/x402-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

541 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

x402-rs

Gasless multi-chain payment facilitator with ERC-8004 reputation

 _  _  _  _  ___  ____      ____  ____
( \/ )/ )( \(__ \(  _ \ ___(  _ \/ ___)
 )  ( ) __ ( / _/ )   /(___))   /\___ \
(_/\_)\_)(_/(____)(__\_)   (__\_)(____/

Live Version Swagger Rust


What is this?

A payment settlement service implementing the HTTP 402 protocol. Users sign payment authorizations off-chain, the facilitator submits them on-chain and pays gas fees.

Includes ERC-8004 on-chain reputation for AI agents across 20 networks (11 mainnets + 9 testnets).

No custody. No trust. Just payments.


Supported Networks

Note: Network counts may be outdated. Verify with: curl -s https://facilitator.ultravioletadao.xyz/supported | jq '[.kinds[].network] | unique | map(select(contains("testnet") or contains("sepolia") or contains("devnet") or contains("fuji") or contains("amoy") or contains("alfajores") | not)) | length'

Mainnets (20)

Network Chain ID Token Explorer
Ethereum 1 USDC etherscan.io
Base 8453 USDC basescan.org
Arbitrum 42161 USDC arbiscan.io
Optimism 10 USDC optimistic.etherscan.io
Polygon 137 USDC polygonscan.com
Avalanche 43114 USDC snowtrace.io
Celo 42220 cUSD celoscan.io
HyperEVM 999 USDC hyperliquid.xyz
Unichain 130 USDC uniscan.xyz
Monad 10143 MON monad.xyz
BSC 56 USDC bscscan.com
SKALE Base 1187947933 USDC.e skale-base-explorer
Scroll 534352 USDC scrollscan.com
Sui - USDC suiscan.xyz
Solana - USDC, AUSD solscan.io
Fogo - USDC fogoscan.com
NEAR - USDC nearblocks.io
Stellar - USDC stellarchain.io
Algorand - USDC allo.info
XRPL - XRP, USDC, RLUSD livenet.xrpl.org

Testnets (17)

Network Chain ID Faucet
Ethereum Sepolia 11155111 faucet.circle.com
Base Sepolia 84532 faucet.circle.com
Arbitrum Sepolia 421614 faucet.circle.com
Optimism Sepolia 11155420 faucet.circle.com
Polygon Amoy 80002 faucet.polygon.technology
Avalanche Fuji 43113 faucet.avax.network
Celo Alfajores 44787 faucet.celo.org
HyperEVM Testnet 333 -
Unichain Sepolia 1301 -
SKALE Base Sepolia 324705682 base-sepolia-faucet.skale.space
Solana Devnet - solfaucet.com
Fogo Testnet - fogoscan.com
NEAR Testnet - near-faucet.io
Stellar Testnet - friendbot
Algorand Testnet - dispenser.testnet.aws.algodev.network
Sui Testnet - suifaucet.com
Monad Testnet 10143 monad.xyz

Supported Stablecoins

Note: Run python scripts/stablecoin_matrix.py for the authoritative stablecoin support matrix.

Token Networks
USDC All 20 payment networks
AUSD Ethereum, Polygon, Arbitrum, Avalanche, Monad, BSC, Solana, Sui
EURC Ethereum, Base, Avalanche
USDT Arbitrum, Celo, Optimism, Monad
PYUSD Ethereum
RLUSD XRPL
XRP XRPL (native)

Full Matrix:

Network USDC AUSD EURC USDT PYUSD
Ethereum Y Y Y - Y
Base Y - Y - -
Arbitrum Y Y - Y -
Optimism Y - - Y -
Polygon Y Y - - -
Avalanche Y Y Y - -
Celo Y - - Y -
BSC Y Y - - -
Monad Y Y - Y -
HyperEVM Y - - - -
Unichain Y - - - -
Scroll Y - - - -
SKALE Base Y - - - -
Solana Y Y - - -
Sui Y Y - - -
Fogo Y - - - -
NEAR Y - - - -
Stellar Y - - - -
Algorand Y - - - -
XRPL Y - - - -

XRPL note: In addition to USDC (issued token), XRPL also supports RLUSD (issued token) and native XRP. These are not EIP-3009 tokens, so they are not tracked by scripts/stablecoin_matrix.py (which only enumerates EIP-3009 stablecoins). See docs/plans/xrpl-native-x402-integration-plan.md.


Quick Start

# Clone
git clone https://github.com/UltravioletaDAO/x402-rs.git
cd x402-rs

# Configure
cp .env.example .env
# Add your private keys (use testnet keys for development)

# Run
cargo run --release --features solana,near,stellar,algorand

# Test
curl http://localhost:8080/health
curl http://localhost:8080/supported | jq '.kinds | length'
# => 121 (networks listed across v1 and v2/CAIP-2 formats)

Docker

docker-compose up -d
curl http://localhost:8080/

API

Endpoint Method Description
/ GET Landing page
/health GET Health check
/version GET Current version
/supported GET List all networks
/verify POST Verify payment authorization
/settle POST Submit payment on-chain (supports escrow with refund extension)
/blacklist GET OFAC sanctioned addresses
/feedback GET/POST ERC-8004 reputation (query/submit)
/identity/:network/:agentId GET Agent identity lookup
/reputation/:network/:agentId GET Agent reputation summary
/discovery/resources GET List registered paid APIs
/discovery/register POST Register a paid endpoint

Example: Check supported networks

curl -s https://facilitator.ultravioletadao.xyz/supported | jq '.kinds[].network'

Example: Settle a payment

curl -X POST https://facilitator.ultravioletadao.xyz/settle \
  -H "Content-Type: application/json" \
  -d '{"payload": "...", "network": "base"}'

Chain-Specific Features

EVM Chains (EIP-3009)

Standard transferWithAuthorization for gasless USDC transfers.

Solana (SPL Token + Token2022)

Supports both SPL Token (USDC) and Token2022 (AUSD) programs.

NEAR (NEP-366)

Meta-transactions with delegate actions for gasless payments.

Stellar (Soroban)

Smart contract-based authorization on Stellar's Soroban VM.

Algorand (Atomic Groups)

Fee pooling via atomic transaction groups. Facilitator signs transaction 0 (fee tx), user signs transaction 1 (payment tx). Based on GoPlausible x402-avm spec.


ERC-8004 Trustless Agents (On-Chain Reputation)

The facilitator integrates ERC-8004 for AI agent identity and reputation across 20 networks.

What is ERC-8004?

Three on-chain registries enabling trust in the agentic economy:

  • Identity Registry - ERC-721 based agent handles with verifiable metadata
  • Reputation Registry - Standardized feedback posting with proof-of-payment
  • Validation Registry - Third-party attestation of agent capabilities

Supported ERC-8004 Networks (20)

Network Type Identity Registry Reputation Registry
Ethereum Mainnet 0x8004A169...9a432 0x8004BAa1...dE9b63
Base Mainnet Same (CREATE2) Same (CREATE2)
Polygon Mainnet Same (CREATE2) Same (CREATE2)
Arbitrum Mainnet Same (CREATE2) Same (CREATE2)
Optimism Mainnet Same (CREATE2) Same (CREATE2)
Celo Mainnet Same (CREATE2) Same (CREATE2)
BSC Mainnet Same (CREATE2) Same (CREATE2)
Monad Mainnet Same (CREATE2) Same (CREATE2)
Avalanche Mainnet Same (CREATE2) Same (CREATE2)
SKALE Base Mainnet Same (CREATE2) Same (CREATE2)
Solana Mainnet Anchor program Anchor program
Ethereum Sepolia Testnet 0x8004A818...4BD9e 0x8004B663...8713
Base Sepolia Testnet Same Same
Polygon Amoy Testnet Same Same
Arbitrum Sepolia Testnet Same Same
Optimism Sepolia Testnet Same Same
Celo Sepolia Testnet Same Same
Avalanche Fuji Testnet Same Same
SKALE Base Sepolia Testnet Same Same
Solana Devnet Testnet Anchor program Anchor program

All EVM mainnet contracts use CREATE2 deterministic deployment (same addresses on every chain). Solana uses a dedicated Anchor program.

ERC-8004 API Endpoints

Endpoint Method Description
/feedback GET List ERC-8004 supported networks
/feedback POST Submit on-chain reputation feedback
/identity/:network/:agentId GET Query agent identity
/reputation/:network/:agentId GET Query reputation summary

Example: Submit Feedback

curl -X POST https://facilitator.ultravioletadao.xyz/feedback \
  -H "Content-Type: application/json" \
  -d '{
    "network": "base-mainnet",
    "agentId": "0x...",
    "rating": 5,
    "tags": ["uptime", "quality"],
    "proofOfPayment": "0x..."
  }'

x402r Escrow Extension (Trustless Refunds)

The facilitator supports the x402r extension for trustless refunds via escrow contracts.

Architecture Overview

                           STANDARD PAYMENT FLOW
  ┌──────────┐    ┌───────────────┐    ┌────────────┐    ┌──────────┐
  │  Buyer   │───>│  Facilitator  │───>│   USDC     │───>│ Merchant │
  │ (signs)  │    │  (pays gas)   │    │ (on-chain) │    │(receives)│
  └──────────┘    └───────────────┘    └────────────┘    └──────────┘
       │                 │
       │  EIP-3009       │  transferWithAuthorization()
       │  signature      │

                           ESCROW PAYMENT FLOW (x402r)
  ┌──────────┐    ┌───────────────┐    ┌──────────────┐    ┌──────────┐
  │  Buyer   │───>│  Facilitator  │───>│ DepositRelay │───>│  Escrow  │
  │ (signs)  │    │  (pays gas)   │    │   (proxy)    │    │ (holds)  │
  └──────────┘    └───────────────┘    └──────────────┘    └──────────┘
       │                 │                    │                  │
       │  EIP-3009       │  executeDeposit()  │  deposit()       │
       │  to PROXY       │                    │                  │
       │                 │                    │                  ▼
       │                 │                    │            ┌──────────┐
       │                 │                    │            │ Merchant │
       │                 │                    └───────────>│(after    │
       │                 │                      release()  │ window)  │
       │                 │                                 └──────────┘
       │                 │
       └─────────────────┴───── Buyer can request refund within window

Supported Networks

Network Chain ID Factory Escrow Status
Base 8453 0x41Cc...A814 0xC409...f6bC Production
Base Sepolia 84532 0xf981...BaC2 0xF7F2...0E58 Testnet

Documentation


Configuration

# Wallet keys (leave empty for AWS Secrets Manager)
EVM_PRIVATE_KEY_MAINNET=
EVM_PRIVATE_KEY_TESTNET=
SOLANA_PRIVATE_KEY_MAINNET=
SOLANA_PRIVATE_KEY_TESTNET=
NEAR_PRIVATE_KEY_MAINNET=
NEAR_ACCOUNT_ID_MAINNET=
STELLAR_SECRET_KEY_MAINNET=
STELLAR_SECRET_KEY_TESTNET=
ALGORAND_MNEMONIC_MAINNET=
ALGORAND_MNEMONIC_TESTNET=

# RPC URLs (premium recommended for production)
RPC_URL_BASE=https://mainnet.base.org
RPC_URL_NEAR_MAINNET=https://rpc.mainnet.near.org
RPC_URL_ALGORAND_MAINNET=https://mainnet-api.algonode.cloud
# ... see .env.example for all networks

Architecture

┌─────────────┐     ┌─────────────────┐     ┌──────────────┐
│   Client    │────▶│   Facilitator   │────▶│  Blockchain  │
│  (signs)    │     │  (pays gas)     │     │  (settles)   │
└─────────────┘     └─────────────────┘     └──────────────┘

Payment Flow:

  1. User signs EIP-3009 (EVM), NEP-366 (NEAR), or atomic group (Algorand)
  2. User sends signed payload to facilitator
  3. Facilitator verifies signature and submits on-chain
  4. Facilitator pays gas, user pays nothing

Deployment

AWS ECS (Production)

# Build & push
docker build -t facilitator:v1.46.0 .
docker push 518898403364.dkr.ecr.us-east-2.amazonaws.com/facilitator:v1.46.0

# Deploy
aws ecs update-service --cluster facilitator-production \
  --service facilitator-production --force-new-deployment

Infrastructure: Terraform configs in terraform/environments/production/

Cost: ~$45/month (Fargate 1vCPU/2GB + ALB)


Development

# Format
cargo fmt

# Lint
cargo clippy --features solana,near,stellar,algorand

# Test
cd tests/integration && python test_facilitator.py

Claude Code Skills

This project includes Claude Code skills for automated development workflows:

Skill Command Description
add-network /add-network scroll Add new blockchain network with automated research, EIP-3009 verification, and deployment
add-erc8004-network /add-erc8004-network polygon Add ERC-8004 reputation support to a network
stablecoin-addition /stablecoin-addition Add new EIP-3009 compatible stablecoins (USDT, EURC, AUSD, etc.)
ship /ship Full automated deployment: commit → build → ECR push → ECS deploy → verify
deploy-prod /deploy-prod Build and deploy Docker image to production ECS
test-prod /test-prod Test production facilitator endpoints

Example: Add a new network

> add facilitator scroll

Claude will:
1. Research chain IDs, RPCs, USDC contracts
2. Verify EIP-3009 support
3. Check wallet balances and logo
4. Request any missing prerequisites
5. Implement all code changes
6. Deploy if all prerequisites met

Adding New Networks

See guides/ADDING_NEW_CHAINS.md for the complete manual checklist.

Quick automated path: Use /add-network {network-name} skill.

Version & Docs Maintenance Checklist

When bumping the version, adding endpoints, or adding networks, update all of these:

File What to update
Cargo.toml version field
src/openapi.rs version in #[openapi(info(...))], endpoint docs, network lists
README.md Version badge, network tables, API endpoint table, ERC-8004 network count
static/index.html Network cards, stats, ERC-8004 showcase badges, i18n strings (EN/ES)
docs/CHANGELOG.md New version entry
src/erc8004/mod.rs supported_networks() when adding ERC-8004 networks

Swagger UI: https://facilitator.ultravioletadao.xyz/docs/ (auto-generated from src/openapi.rs)


Acknowledgments

Special thanks to:


Links


License

Apache 2.0


Built by Ultravioleta DAO

About

x402 payments in Rust: verify, settle, and monitor payments over HTTP 402 flows

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Rust 63.8%
  • Python 19.3%
  • HTML 8.3%
  • HCL 4.9%
  • Shell 1.7%
  • JavaScript 1.1%
  • Other 0.9%