HTTP 402 "Payment Required" was proposed in 1996. For almost 30 years, it remained unused — a specification without implementation.
In late 2025, Coinbase, Cloudflare, and the Linux Foundation announced joint work on x402. In early 2026, Binance and XRP Ledger followed. The industry is moving toward programmable, agent-ready payments.
But all of them released documentation, not code.
I decided to build it.
The Problem
AI agents cannot pay for services.
Every API call, every database query, every compute cycle requires manual intervention. API keys. Centralized billing. Human approval.
This breaks the promise of autonomous agents.
If an agent can think, it should be able to pay.
The Solution: AxilProtocolV1
AxilProtocolV1 is a smart contract on Monad that implements the x402 standard with automatic reward distribution, replay protection, and gas optimization.
Intent-Based Payments
Every transaction starts with an intent — a packed bytes32 value:
bytes32 packedIntent = bytes32(uint256(bucket) << 128 | uint256(mask));
· bucket (128 bits): service category (1 = API, 2 = NFT, 3 = subscription)
· mask (128 bits): specific item ID
This allows human-readable payments in MetaMask. Instead of a hash, users see "Buy API Access #12345".
EIP-712 Signatures
All payments are signed using EIP-712, the structured data standard. This means:
· Signatures cannot be forged
· Signatures are bound to a specific chain and contract
· Users see what they sign before confirming
The contract also supports IERC1271 for smart contract wallets like Safe.
Bitmap Replay Protection
Traditional replay protection uses nonce mappings — expensive and unscalable.
AxilProtocol uses bitmap tracking:
mapping(uint128 => uint128) public intentBitmap;
Each bucket holds 128 intents in a single storage slot. 16,384 intents in two slots. Gas savings: 8.5x.
if ((intentBitmap[bucket] & mask) != 0) revert Axil__IntentAlreadyExecuted();
intentBitmap[bucket] |= mask;
Automatic Distribution
When a user pays 100 MON:
Payment: 100 MON
├─ 99 MON → Merchant (instant settlement)
└─ 1 MON → Protocol fee
├─ 0.2 MON → Burn (deflation)
├─ 0.2 MON → Agent (bot)
├─ 0.2 MON → User (cashback)
├─ 0.2 MON → Validator pool
└─ 0.2 MON → DEX broker
All automatic. One transaction, five payouts.
Technical Specifications
Test Coverage
· 52 unit tests covering all core functions
· 10 million fuzzing runs with random inputs
· 11 attack vectors tested and blocked
Gas Usage
Function Gas Cost at $0.0216/MON
execute() 366,000 $0.0008
packIntent() 644 $0.0000014
Deployment 5.48M $0.12
Security
· OpenZeppelin: AccessControl, ReentrancyGuard, Pausable
· EIP-712: structured signatures
· IERC1271: smart wallet support
· Bitmap: O(1) replay protection
· Emergency pause and role transfer functions
Development Story
The code was developed over two weeks in February 2026. On February 15th, ten minutes before the Moltiverse deadline, the author's hardware failed — GPU, HDD, and RAM stopped working. The deployment was completed on a backup machine.
The contract is now live on Monad Testnet.
Current Status
· Contract deployed: 0xB3A59e559B470Ce9Edc1Ccf70B912F8A021a4552
· Verified on Monad Explorer (Socialscan)
· 66 clones on GitHub in 3 days
· 28 unique visitors
· All tests passing (3 protective failures expected)
Open Source
The code is MIT licensed and available on GitHub:
https://github.com/AxilProtocolV1/AxilProtocolV1
Next Steps
· V2 release: end of 2026
· Mainnet deployment
· Cloudflare Workers integration
· 100+ tests with 90%+ coverage
Conclusion
x402 is becoming an industry standard. Coinbase, Cloudflare, Binance, and XRP Ledger are all moving in this direction.
AxilProtocolV1 is the first production-ready implementation.
It works. It's tested. It's open source.
Built for Moltiverse 2026 | Monad Testnet | MIT License
#x402 #monad #coinbase #cloudflare #binance #xrp #ripple #multiversx #paypal #linuxfoundation #ethereum #base #bnbchain #solana #web3 #blockchain #crypto #aiagents #http402
Top comments (0)