Protocol
MicroAI Paygate currently implements a custom x402-style protocol. It uses HTTP 402 Payment Required, EIP-712 typed data, custom X-402-* retry headers, and gateway-signed receipts.
It is not official x402-compatible yet because it does not use the official header contract or facilitator-backed settlement path.
Flow
- Client sends an unsigned request to the gateway.
- Gateway returns
402 Payment Requiredwith apaymentContext. - Client signs the payment context with EIP-712.
- Client retries with
X-402-Signature,X-402-Nonce, andX-402-Timestamp. - Gateway sends the signed payload to the Rust verifier.
- Verifier recovers the wallet, checks chain ID, timestamp, and nonce.
- Gateway calls the configured AI provider.
- Gateway signs a receipt over the request and response hashes.
- Client decodes and verifies the receipt.
EIP-712 Domain
TypeScript
const domain = {
name: "MicroAI Paygate",
version: "1",
chainId: paymentContext.chainId,
verifyingContract: ethers.ZeroAddress,
};
Payment Type
TypeScript
const types = {
Payment: [
{ name: "recipient", type: "address" },
{ name: "token", type: "string" },
{ name: "amount", type: "string" },
{ name: "nonce", type: "string" },
{ name: "timestamp", type: "uint256" },
],
};
Payment Context Fields
recipient: recipient wallet address.token: display token symbol, currentlyUSDC.amount: requested payment amount as a string.nonce: one-time replay protection value.chainId: EIP-712 chain ID.timestamp: signature freshness timestamp.
Receipt Fields
Receipts include:
- payment payer, recipient, amount, token, chain ID, and nonce.
- service endpoint.
request_hash.response_hash.- gateway signature.
- gateway server public key.
Receipt verification must use a trusted gateway public key distributed out of band. A client must not treat a public key embedded in the receipt as the trust anchor by itself.