Mesh Connects x402 Payments With Masumi Escrow on Cardano
The package lets developers charge for APIs and digital content, with tools for payouts, refunds, and disputes involving AI agent tasks.
By SongMarketCap
Mesh has added @meshsdk/x402 to its Cardano development toolkit, connecting access to online services with blockchain payments. Alongside direct payments, the package supports Masumi escrow, where funds remain locked until the conditions for withdrawal or refund are met.
x402 Payments for APIs and Digital Content
Mesh is an open-source TypeScript toolkit for building Cardano applications. Developers use it to connect wallets, construct and sign transactions, and interact with smart contracts. Its x402 package brings payments into the communication between an application requesting a service and the server providing it.
When an application requests paid content, the server returns an HTTP 402 Payment Required response containing the price and payment terms. The client builds and signs a transaction, then retries the request with the payment information.
A facilitator checks the signed transaction, submits it to Cardano, and reports its confirmation status. For direct payments, the server releases the content once the required confirmation conditions are satisfied.
The facilitator holds no user private keys. Its checks cover the network, recipient, asset, amount, and consistency with the server’s offer.
Payments can be denominated in ADA or Cardano native tokens. Funds can go to a wallet address, a developer’s own smart contract, or Masumi escrow.
Masumi Escrow for AI Agent Tasks
For a service an AI agent has yet to perform, payment can be locked in Masumi’s vested_pay contract. The provider signs an offer containing the task terms and deadlines for payment, result submission, withdrawal, and dispute settlement.
A successful x402 payment in this model locks the funds in escrow. Recording the result and paying the provider require subsequent transactions.
In the standard workflow, the provider records a cryptographic hash of the result before the submission deadline. Funds become available for withdrawal after the specified unlock time.
The package also supports refund procedures. If no result is submitted before the relevant deadline, the buyer can reclaim funds under the contract’s rules. Dispute settlement requires the designated quorum of escrow administrator signatures and follows the contract’s timing conditions.
Mesh Tools Cover What Happens After Payment
The package includes transaction builders for submitting result hashes, withdrawing funds, requesting or authorizing refunds, and settling disputes. Developers can therefore connect the initial purchase with the later stages of a paid task.
Before signing a Masumi payment, the client checks the provider’s signature, escrow address, and deadlines. The documentation lists Cardano mainnet, Preprod, and Preview support, while its published examples use Preprod.
An application charging ADA for an agent task can use the same package to lock payment in escrow, record a result hash, and prepare the eventual payout. Refunds and dispute settlement follow separate transaction paths governed by the original offer.