transferWithAuthorization.
It is written for sellers, buyers, and AI coding agents implementing either
side of the payment flow.
This current path uses Permit2 and applies to MegaETH, BSC, BOT Chain, BOT
Chain testnet, and Tempo. Do not use the legacy BSC or MegaETH forwarders for
new integrations.
How the flow works
paymentRequirements.payTois the Meridian facilitator, not the seller walletpaymentRequirements.assetis the ERC-20 token the buyer pays with- The buyer approves Permit2, not the facilitator and not the exact proxy
- The buyer signs with
x402ExactPermit2Proxyas the Permit2 spender witness.tois the Meridian facilitator- The seller keeps the Meridian API key on the backend
Prerequisites
Seller:- A Meridian organization
- An organization API key from
https://mrdn.finance/dev/api-keys - A backend endpoint that can receive
paymentPayloadfrom the buyer
- A wallet on the selected chain
- Balance of the selected ERC-20 token
- Permit2 allowance for that token
Network constants
The token addresses below are Meridian’s default payment tokens for each network. If your application accepts another transferable ERC-20 on the same chain, use that token address inpaymentRequirements.asset and use that
token’s real name, version, and decimals.
Seller setup
1. Create a Meridian API key
Seller-side setup starts in Meridian:- Connect the seller wallet at
https://mrdn.finance - Open
https://mrdn.finance/dev/api-keys - Create an organization-scoped API key
- Store the public
pk_...key on the server
Authorization header when calling Meridian:
2. Choose the network and amount
Amounts must use the selected token’s base units. Do not assume every token has 6 decimals.3. Build paymentRequirements
Use the ERC-20 token address as asset. Keep payTo pointed at the Meridian
facilitator.
4. Receive paymentPayload
The buyer sends raw JSON, not a transaction they submit on-chain.
Build or retrieve the matching paymentRequirements server-side; do not trust
buyer-supplied requirements for pricing, recipient, network, or token selection.
5. Settle with Meridian
CallPOST /v1/settle from the seller backend. Do not expose the Meridian API
key to an untrusted client.
Buyer setup
1. Select a payment requirement
Use the seller-provided requirement for the network and token the buyer will pay with.2. Approve Permit2
The buyer approves the canonical Permit2 contract as spender for the token inpaymentRequirements.asset. The buyer does not approve the x402ExactPermit2Proxy or the facilitator
to spend their tokens!
3. Sign the Permit2 authorization
Sign a Permit2 witness transfer. The EIP-712 verifying contract is Permit2, the Permit2 spender isx402ExactPermit2Proxy, and the witness destination is the
Meridian facilitator.
4. Send paymentPayload to the seller
Serialize bigint values as decimal strings.
permit2612 object to
paymentPayload.payload. Only use this shortcut for tokens you have confirmed
implement permit().
Checklist for AI agents
- Read the seller’s existing route structure before adding payment handling
- Keep settlement on the backend
- Use
asset = token address - Use
payTo = Meridian facilitator - Use
permit.spender = x402ExactPermit2Proxy - Use
domain.verifyingContract = Permit2 - Use
witness.to = Meridian facilitator - Convert every bigint in
paymentPayloadto a string before JSON encoding - Do not add legacy forwarder logic for new integrations
Common mistakes
- Setting
payToto the seller wallet - Approving the exact proxy or facilitator instead of Permit2
- Signing with Permit2 as spender instead of
x402ExactPermit2Proxy - Setting
witness.toto anything other than the Meridian facilitator - Reusing hardcoded decimals from another chain
- Sending raw
bigintvalues through JSON - Putting the Meridian API key in browser code