Overview
Aether uses the x402 payment protocol for machine-to-machine payments. It’s based on HTTP status code 402 (Payment Required) combined with pre-signed Solana transactions.How x402 Works
- Request - Client requests a paywalled resource
- 402 Response - Server returns payment requirements
- Payment - Client creates and signs a transaction
- Submit - Client retries request with X-Payment header
- Verify - Server verifies the payment
- Settle - Server submits transaction to Solana
- Deliver - Server returns the resource
Supported Assets
| Asset | Network | Mint Address |
|---|---|---|
| USDC | Devnet | 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU |
| USDC | Mainnet | EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v |
| ATHR | Mainnet | 5abiPeWqRLYb21DWNGYRFwrABML24dYuGn39ZpPYpump |
Creating Payments
Using SettlementAgent
Payment Header Format
The payment is base64-encoded JSON:Verifying Payments
Using X402FacilitatorServer
Verification Checks
The facilitator verifies:| Check | Description |
|---|---|
| Version | Must be x402Version: 1 |
| Scheme | Must match requirements |
| Network | Must match (devnet/mainnet) |
| Amount | Must equal maxAmountRequired |
| Recipient | Must match payTo address |
| Asset | Must match token mint |
| Expiration | validBefore must be in future |
| Nonce | Must be unique (replay protection) |
| Signature | Transaction signature must be valid |
| Balance | Payer must have sufficient USDC |
Settling Payments
After verification, settle to execute the transfer:Multi-Network Support
The facilitator supports both devnet and mainnet:Error Handling
Common Errors
| Error | Cause | Solution |
|---|---|---|
Insufficient USDC balance | Not enough funds | Fund the wallet |
Payment expired | validBefore passed | Create new payment |
Replay detected | Nonce already used | Create new payment |
Amount mismatch | Wrong amount | Match requirements |
Invalid signature | Corrupted transaction | Re-sign transaction |
Error Handling Example
ATHR Token Benefits
Pay with ATHR token for discounts:| Payment Method | Marketplace Fee |
|---|---|
| USDC | 10% commission |
| ATHR | 7.5% commission (25% off) |
Best Practices
- Verify before settle - Always verify payment validity first
- Handle expiration - Payments expire after 2 minutes by default
- Check network - Ensure devnet payments go to devnet, mainnet to mainnet
- Log transactions - Store
txHashfor records - Retry with backoff - Network issues may require retries
