A set of Ethereum-compatible smart contracts that standardize status codes, policy checks, and intent validation for Web3 transactions, designed to integrate cleanly with an HTTP/x402 gateway and agent layer.
erc1066-x402 is an early-stage TypeScript project in the AI payments / x402 ecosystem, focused on agents, blockchain, evm, package. It currently has 2 GitHub stars and 0 forks, and sits alongside related tools like piprail, x402-dart, tdm-integration-kit.
ERC-1066-x402 is a set of Ethereum-compatible smart contracts that standardize status codes, policy checks, and intent validation for Web3 transactions. It integrates with an HTTP/x402 gateway and agent layer to provide machine-readable status codes for autonomous decision-making.
Key Features:
canExecute) with machine-readable statusERC-1066-x402 is designed to be network-agnostic. We provide standardized status mappings for:
For technical details, see MULTI_CHAIN.md.
Without ERC1066-x402:
With ERC1066-x402:
0x01, 0x10, 0x54) that agents can branch on directly0x54 (INSUFFICIENT_FUNDS) maps to HTTP 402 with X-Payment-Required headerAI Agent Autonomy: Agents can make decisions based on status codes without parsing error messages
if result.status == "0x54": # INSUFFICIENT_FUNDS
request_payment()
elif result.status == "0x01": # SUCCESS
execute()
Reduced Gas Costs: Single-byte status codes save ~200-500 gas per validation vs. string errors
Easier Monitoring: Standardized codes enable cross-protocol analytics and alerting
x402 Compliance: Built-in HTTP 402 mapping for payment-required scenarios
| Component | Status | Notes |
|---|
| Component | Status | Notes |
|---|---|---|
| Multi-Chain | ⏳ v0.3.0 Beta | EVM, Solana (Devnet), Sui (Testnet) supported |
| x402 Standard | ✅ v2 Aligned | Full compatibility with transport v2 + exact scheme |
| Smart Contracts | ✅ Deployed | Metis, Mantle, Avalanche, Solana, Sui |
| SDKs | ✅ v0.1.0/v0.2.0 | TS (@hyperkit/erc1066-x402 v0.1.0) and Python (hyperkitlabs-erc1066-x402 v0.2.0) |
| Test Coverage | ✅ 100% Green | 38/38 EVM tests passing + multi-chain simulation |
exact scheme specification.@solana/web3.js and Borsh encoding.@mysten/sui.js.Ensure you have the required tools for your target chains:
One-command setup for Solana & Sui (WSL/Linux/macOS):
# Solana, Rust, and Anchor
curl --proto '=https' --tlsv1.2 -sSfL https://solana-install.solana.workers.dev | bash
# Sui Toolchain
curl -sSfL https://raw.githubusercontent.com/Mystenlabs/suiup/main/install.sh | sh && suiup install sui@testnet
git clone https://github.com/hyperkit-labs/erc1066-x402.git
cd erc1066-x402
npm install
forge install
npm test
# Set your private key
export PRIVATE_KEY=your_private_key_here
# Deploy to Hyperion Testnet
npm run deploy:hyperion:testnet
cd packages/gateway
cp env.template .env
# Edit .env with your contract addresses
npm run dev
For detailed setup, see GETTING_STARTED.md
graph TB
subgraph OffChain[Off-Chain Layer]
Gateway[Gateway Service<br/>TypeScript/Fastify]
SDK_TS[TypeScript SDK]
SDK_PY[Python SDK]
Agents[AI Agents/Wallets]
end
subgraph OnChain[On-Chain Layer]
Executor[IntentExecutor]
Validator[BaseIntentValidator]
Registry[PolicyRegistry]
StatusCodes[StatusCodes Library]
end
Agents --> SDK_TS
Agents --> SDK_PY
SDK_TS --> Gateway
SDK_PY --> Gateway
Gateway --> Executor
Executor --> Validator
Validator --> Registry
Validator --> StatusCodes
See Architecture Overview for detailed diagrams.
The gateway supports any EVM-compatible chain via Chainlist. Tested networks:
Network-Agnostic Design: The gateway automatically discovers RPC endpoints via Chainlist, so you can add new networks without code changes. See Network Configuration for details.
📚 Complete Documentation Index
We follow the x402 v2 Standard for transport and ERC-1066 for semantics. See the Specs Directory for details:
npm install
forge install
cd packages/gateway
npm install
pip install hyperkitlabs-erc1066-x402
npm install @hyperkit/erc1066-x402
An AI agent uses ERC1066-x402 to handle payment-required scenarios:
from erc1066_x402 import ERC1066Client, Intent
client = ERC1066Client("https://gateway.example.com")
intent = Intent(
sender="0x...",
target="0x...",
data="0x...",
value="1000000000000000", # 0.001 ETH
nonce="1",
policyId="0x..."
)
# Pre-flight validation
result = client.validate_intent(intent, chain_id=133717)
if result.status == "0x54": # INSUFFICIENT_FUNDS
# Gateway returns HTTP 402 with X-Payment-Required header
# Agent requests payment from user
payment_url = f"{gateway_url}/pay?intent={intent_hash}"
request_payment(payment_url)
elif result.status == "0x01": # SUCCESS
# Execute immediately
client.execute_intent(intent, chain_id=133717)
elif result.status == "0x20": # TOO_EARLY
# Retry after Retry-After header delay
retry_after = result.httpCode == 202
schedule_retry(retry_after)
The gateway automatically maps status codes to HTTP responses:
// Gateway receives intent validation request
POST /intents/validate
{
"sender": "0x...",
"target": "0x...",
"value": "1000000000000000"
}
// If balance insufficient, returns:
HTTP 402 Payment Required
X-Payment-Required: true
{
"status": "0x54",
"intentHash": "0x...",
"message": "Insufficient funds"
}
Deploy once, use across all supported chains:
# Deploy to multiple networks
npm run deploy:hyperion:testnet
npm run deploy:metis:sepolia
npm run deploy:mantle:testnet
# Gateway automatically discovers RPCs via Chainlist
# No hardcoded network configs needed
from erc1066_x402 import ERC1066Client, Intent
client = ERC1066Client("http://localhost:3001")
intent = Intent(
sender="0x...",
target="0x...",
data="0x...",
value="0",
nonce="1",
policyId="0x..."
)
result = client.validate_intent(intent, chain_id=133717)
if result.status == "0x01":
client.execute_intent(intent, chain_id=133717)
import { ERC1066Client } from '@hyperkit/erc1066-x402';
const client = new ERC1066Client('http://localhost:3001');
const result = await client.validateIntent(intent, 133717);
main - Production-ready code (protected, requires PR + reviews)develop - Integration branch for feature developmentfeature/* - Feature branches (merge to develop)See Development Guide for details.
# All tests
npm test
# Contract tests only
forge test
# With coverage
npm run test:coverage
We welcome contributions! See CONTRIBUTING.md for guidelines.
Gateway won't start:
lsof -i :3001.env file exists and has correct contract addressesContracts fail to deploy:
PRIVATE_KEY has 0x prefix (scripts handle this automatically)SDK import errors:
npm install in SDK directoryFor more help: See Troubleshooting Guide
ERC1066-x402 maps onchain status codes to HTTP/x402 responses, enabling seamless integration with payment gateways and AI agents.
| Status Code | Meaning | HTTP Code | Headers | Agent Action |
|---|---|---|---|---|
0x01 |
SUCCESS | 200 | - | Execute immediately |
0x11 |
ALLOWED | 200 | - | Execute immediately |
0x10 |
DISALLOWED | 403 | - | Deny, inform user |
0x54 |
INSUFFICIENT_FUNDS | 402 | X-Payment-Required: true |
Request payment |
0x20 |
TOO_EARLY | 202 | Retry-After: 60 |
Retry later |
0x21 |
TOO_LATE | 410 | - | Reject, expired |
0x22 |
NONCE_USED | 409 | - | Reject, replay detected |
0x50 |
TRANSFER_FAILED | 500 | - | Retry or investigate |
0xA0 |
INVALID_FORMAT | 400 | - | Fix intent structure |
0xA2 |
UNSUPPORTED_CHAIN | 421 | - | Use different chain |
Key Insight: The 0x54 → HTTP 402 mapping enables standardized payment flows. When an agent receives HTTP 402 with X-Payment-Required, it knows to request payment before retrying.
See Status Codes Specification for complete list.
MIT License - see LICENSE for details.
For detailed technical specifications, see:
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.
Dart implementation of the x402 payment protocol. 🎯
Developer integration tools for adding TDM payments to AI agents, apps, and workflows. CLI, MCP server, and copy-paste examples
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.
Drop-in OpenAI Typescript client with transparent x402 payment support.
TypeScript Interface for Machine Payments Protocol
Production-ready x402 facilitator server.
Rust SDK for the x402 payment protocol.