r402-aptos
Aptos chain support for the x402 payment protocol, part of the
r402 workspace.
Highlights
- Exact scheme — a sender-signed
primary_fungible_store::transferof a fungible asset (USDC by default). The facilitator is the optionalfeePayer: it verifies the payload, adds its signature, and submits. - CAIP-2 networks —
aptos:1(mainnet) andaptos:2(testnet). - TS payload encoding — outer base64 of UTF-8 JSON
{ transaction: [u8], senderAuthenticator: [u8] }. Inner bytes are BCS fromaptos-sdk0.6.0 (SimpleTransaction+AccountAuthenticator). - Gas caps — sponsored txs reject
max_gas_amount > 500_000andgas_unit_price > 1000. - In-process facilitator —
aptos-sdkverify (signature, simulate, FA balance) and settle. Duplicate settle is blocked bySettlementCachekeyed by the base64 payload.
Cargo Features
| Feature | Surface |
|---|---|
client |
Buyer-side sponsored primary_fungible_store::transfer signing. |
server |
Server-side PriceTag generation. |
facilitator |
On-chain verify and settle via aptos-sdk 0.6. |
telemetry |
tracing instrumentation. |
full |
All of the above. |
Quick Start (server price tag)
use ;
let tag = price_tag;
Documentation
- Crate docs: https://docs.rs/r402-aptos
- Project README:
../../README.md
License
Dual-licensed under MIT and Apache-2.0.