M402 Brings Private AI Agent Payments to Midnight
Hack Buenos Aires project M402 adds a privacy layer to x402 payments, allowing AI agents to access paid API services without publicly exposing the payer. The team demonstrated the flow on Midnight test infrastructure with selective disclosure and relayed payments to Base.
By SongMarketCap
M402, one of the projects presented among the Midnight hackathon winners in Buenos Aires, has demonstrated a system for private AI agent payments. The project keeps the core x402 model for paid API access while adding payer privacy through Midnight.
During the demo, an AI agent searched for a weather API, checked available funds and initiated payment without manual transaction handling. The current implementation remains in a test environment.
M402 Adds Privacy to x402 Payments
x402 uses the HTTP 402 Payment Required response to let applications and AI agents identify paid digital resources, complete payment and continue accessing the requested service.
M402 preserves that workflow while changing how the payer is represented during the transaction.
API providers still publish the service they offer and its price. Privacy is applied to the user or agent making the payment.
The project also incorporates Midnight’s selective disclosure capabilities. Payment information can remain private during normal use while specific transaction details can be revealed later when required for purposes such as accounting or tax reporting.
NIGHT Becomes a Shielded Credit for API Access
One technical challenge addressed by the team is that NIGHT is an unshielded asset.
M402 uses a vault where users deposit
NIGHT and receive an internal shielded credit called mNIGHT. That credit can then be used within the platform to pay for supported x402 services.
When an agent requests a paid resource, the payment flow provides proof that the required value has been supplied without exposing the same payer information that would remain visible in a standard unshielded transaction.
The team described two service models. One covers APIs built natively for Midnight. The second uses a relayer to connect Midnight based agents with existing x402 services running on other networks.
In the demonstration, the agent was charged through the Midnight side while the relayer paid the external service using test USDC on Base Sepolia.
CLI Demo Automates the Payment Flow
M402 also includes a web interface for listing API services and a command line tool designed for AI agents.
During the live demonstration, the agent was instructed to find a service providing weather information for Buenos Aires and pay for access if required.
The CLI identified available services, synchronized the wallet, checked the balance, determined the API price and proceeded through the payment flow. The tool is designed to abstract Midnight wallet management and payment execution behind commands that software agents can call directly.
The project’s source code is publicly available as part of the hackathon work. The team said the relayer still needs to be deployed publicly and prepared for higher traffic before broader use.
Cardano L1 was not part of the payment path demonstrated for M402. The current architecture combines Midnight privacy infrastructure, x402 API payments and a relayer to Base Sepolia. The working testnet prototype already covers private payer execution, selective disclosure and autonomous API payments, while mainnet deployment and a production ready relayer remain pending.