> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://mpp.dev/api/mcp` to find what you need.

# Use MPP with x402 \[Connect existing x402 services and clients]

MPP and x402 are complementary protocols. You can add MPP to an x402 client or server with a few lines of code while preserving x402 support.

## Protocol comparison

See [MPP vs x402](/mpp-vs-x402) for a full comparison.

| | x402 | MPP |
|---|---|---|
| **Challenge** | `PAYMENT-REQUIRED` header | `WWW-Authenticate: Payment` header |
| **Credential** | `PAYMENT-SIGNATURE` header | `Authorization: Payment` or an advertised alternate field |
| **Receipt** | `PAYMENT-RESPONSE` header | `Payment-Receipt` header |
| **Flow used here** | x402 v2 EIP-3009 `exact` | EVM `charge` |
| **Payment rails** | Registered blockchain network mechanisms | Stablecoins, cards, Lightning, and custom methods |
| **Error format** | Custom | [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457) Problem Details |
| **Idempotency** | Optional Payment Identifier extension | Challenge identity plus standard `Idempotency-Key` guidance |

## Server

Choose the server setup that matches your current integration shape:

1. **Add MPP to an x402 server**—keep your existing x402 route table and resource server, then wrap them with `mppx`.
2. **Start with `mppx`**—create a new route that serves native MPP and x402 clients.

### Add MPP to an x402 server

Install `mppx`. Keep your existing x402 SDK packages and configuration.

:::code-group
```bash [npm]
$ npm install mppx viem
```

```bash [pnpm]
$ pnpm add mppx viem
```

```bash [bun]
$ bun add mppx viem
```
:::

Start with your existing x402 SDK route:

```ts [server.ts]
import { HTTPFacilitatorClient, type RoutesConfig, x402ResourceServer } from '@x402/core/server'
import { ExactEvmScheme } from '@x402/evm/exact/server'
import { paymentMiddleware } from '@x402/express'
import express from 'express'

const app = express()
const facilitator = new HTTPFacilitatorClient({
  url: 'https://x402.org/facilitator',
})
const resourceServer = new x402ResourceServer(facilitator).register(
  'eip155:84532',
  new ExactEvmScheme(),
)
const routes = {
  'GET /api/data': {
    accepts: [
      {
        network: 'eip155:84532',
        payTo: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
        price: '$0.01',
        scheme: 'exact',
      },
    ],
    description: 'Premium data access',
    mimeType: 'application/json',
  },
} satisfies RoutesConfig

app.use(paymentMiddleware(routes, resourceServer))

app.get('/api/data', (req, res) => {
  res.json({ data: 'premium content' })
})
```

Replace the x402 middleware import with the MPP compatibility wrapper. Keep the route table, resource server, facilitator, and handler unchanged:

```ts [server.ts]
import { HTTPFacilitatorClient, type RoutesConfig, x402ResourceServer } from '@x402/core/server'
import { ExactEvmScheme } from '@x402/evm/exact/server'
import express from 'express'
import { mpp } from 'mppx/x402/express' // [!code focus]

const app = express()
const facilitator = new HTTPFacilitatorClient({
  url: 'https://x402.org/facilitator',
})
const resourceServer = new x402ResourceServer(facilitator).register(
  'eip155:84532',
  new ExactEvmScheme(),
)
const routes = {
  'GET /api/data': {
    accepts: [
      {
        network: 'eip155:84532',
        payTo: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
        price: '$0.01',
        scheme: 'exact',
      },
    ],
    description: 'Premium data access',
    mimeType: 'application/json',
  },
} satisfies RoutesConfig

const secretKey = process.env.MPP_SECRET_KEY
if (!secretKey) throw new Error('Set MPP_SECRET_KEY to at least 32 random bytes.')

app.use(mpp(routes, resourceServer, { secretKey })) // [!code focus]

app.get('/api/data', (req, res) => {
  res.json({ data: 'premium content' })
})
```

The wrapper delegates x402 Credentials, lifecycle hooks, verification, and settlement to the official x402 adapter. For the first compatible extension-free EIP-3009 `exact` requirement, it also advertises MPP Challenges (payment offers) for Tempo, a payments blockchain, and for EVM payment on the chain in your existing x402 requirement. The source-chain MPP option verifies and settles through the same x402 resource server. Requirements with x402 extensions remain x402-only so their semantics aren't lost.

:::note
The x402 compatibility wrapper converts atomic payment requirements to display units automatically, so keep your existing x402 route configuration unchanged. When configuring `mppx.evm.charge` directly, convert atomic amounts first—for six-decimal USDC, `10000` becomes `0.01`.
:::

#### Use another x402 adapter

The same compatibility layer wraps official Hono, Next.js, and MCP integrations:

| Runtime | Import | Wrapper |
|---|---|---|
| Express | `mppx/x402/express` | [`mpp(routes, server, config)`](/sdk/typescript/x402/express) |
| Hono | `mppx/x402/hono` | [`mpp(routes, server, config)`](/sdk/typescript/x402/hono) |
| MCP | `mppx/x402/mcp` | [`mpp(server, config)(handler)`](/sdk/typescript/x402/mcp) |
| Next.js proxy | `mppx/x402/next` | [`mppProxy(routes, server, config)`](/sdk/typescript/x402/next) |
| Next.js route | `mppx/x402/next` | [`mpp(handler, route, server, config)`](/sdk/typescript/x402/next) |

### Run x402 inline with `mppx`

For a new service, configure `mppx` directly when one route must serve native MPP and x402 clients.

```ts [server.ts]
import { Mppx, evm } from 'mppx/express'
import express from 'express'

const app = express()

const mppx = Mppx.create({
  methods: [
    evm.charge({
      currency: evm.assets.baseSepolia.USDC,
      recipient: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
      // [!code focus:start]
      x402: {
        facilitator: 'https://x402.org/facilitator',
      },
      // [!code focus:end]
    }),
  ],
  secretKey: process.env.MPP_SECRET_KEY!,
})

app.get(
  '/api/data',
  mppx.evm.charge({
    amount: '0.01',
    description: 'Premium data access',
  }),
  (req, res) => {
    res.json({ data: 'premium content' })
  },
)
```

The handler stays unchanged. `mppx`:

* Returns MPP and x402 Challenges on `402` responses
* Accepts MPP and x402 Credentials
* Calls the configured facilitator to verify and settle x402 payments
* Returns the Receipt header that matches the client's protocol

This flow also supports body-bearing and route-scoped endpoints. Standard x402 clients don't need the optional `mppx` route-binding extension.

### Advanced server options

#### Accept standard x402 Credentials

Keep the default `routeBinding: 'required'` so every x402 Credential for a scoped route includes the `mppx` extension and a route-bound nonce. Set `routeBinding: 'resource'` only when scoped routes must accept standard x402 clients that don't implement the extension.

```ts twoslash [server.ts]
import { evm } from 'mppx/server'

const method = evm.charge({
  currency: evm.assets.baseSepolia.USDC,
  recipient: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
  // [!code hl:start]
  x402: {
    facilitator: 'https://x402.org/facilitator',
    routeBinding: 'resource',
  },
  // [!code hl:end]
})
```

Resource binding compares the echoed resource URL and payment requirements. Both modes verify any body digest against the request. The default required binding also binds MPP scope, opaque values, and metadata to the signature, but excludes clients that don't implement the extension.

### Recognize a wallet before charging

Use x402's sign-in-with-x (SIWX) extension when an entitled wallet can access the resource without another payment. Configure `x402.siwx` on a native `evm.charge` method; it is separate from the official x402 adapter wrappers above.

```ts twoslash [server.ts]
import { Mppx, Store, evm } from 'mppx/server'

declare const entitledWallets: ReadonlySet<string>

const mppx = Mppx.create({
  methods: [evm.charge({
    currency: evm.assets.baseSepolia.USDC,
    recipient: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
    // [!code hl:start]
    x402: {
      facilitator: 'https://x402.org/facilitator',
      siwx: {
        grant: ({ address }) => entitledWallets.has(address.toLowerCase()),
        origin: 'https://api.example.com',
        store: Store.memory(),
      },
    },
    // [!code hl:end]
  })],
})

export async function handler(request: Request) {
  const result = await mppx.charge({ amount: '0.01' })(request)
  if (result.status === 402) return result.challenge
  return result.withReceipt(Response.json({ data: 'premium content' }))
}
```

`grant` receives the verified address, chain ID, and a request copy. Return `true` only for wallets your application already entitles; return `false` to keep the normal payment flow. A granted proof produces a successful Receipt but moves no funds. SIWX is an access decision, not a payment or a substitute for required route identity checks.

Use a fixed public `origin` and a shared atomic `store` in production. `Store.memory()` only covers one process. Proofs are single-use, including when `grant` declines; composed offers sharing a backend must share the same store object. Without a viem `client`, verification accepts EOA signatures only; provide a client on the offer's chain for smart-wallet signatures.

Wrap the underlying fetch so the client tries SIWX before payment:

```ts twoslash [client.ts]
import { Fetch, evm } from 'mppx/client'
import { Siwx } from 'mppx/x402'
import { privateKeyToAccount } from 'viem/accounts'

const account = privateKeyToAccount(
  '0x0123456789012345678901234567890123456789012345678901234567890123',
)
const fetch = Fetch.from({
  // [!code hl:start]
  fetch: Siwx.wrapFetch(globalThis.fetch, { account }),
  // [!code hl:end]
  methods: [evm.charge({
    account,
    currencies: [evm.assets.baseSepolia.USDC],
    maxAmount: '1.00',
  })],
})
console.log((await fetch('https://api.example.com/report')).status)
// @log: 200
```

The wrapper retries one unpaid `402` with a signed proof. If the wallet isn't entitled and the server still returns `402`, the outer payment client pays as usual. It doesn't retry streamed uploads, redirected responses, existing payments, or single-use DPoP and HTTP message signatures. See [`Siwx`](/sdk/typescript/x402/Siwx) for the complete API and retry rules.

### Configure token metadata

EVM and x402 configuration accepts a raw token address, a chain-indexed token from `viem/tokens`, a token resolved to one chain, or known x402 asset metadata such as `evm.assets.baseSepolia.USDC`. Prefer known assets: they include the EIP-3009 signing domain and chain, not only the address and decimals.

With a resolved token such as `usdc(84532)`, `chainId` and decimals are inferred, but you still supply EIP-3009 `authorization` metadata. A chain-indexed token needs `chainId`; a raw address needs `chainId`, decimals, and authorization metadata. A token resolved to another chain doesn't match an offer. See [`x402.assets`](/sdk/typescript/x402/assets).

## Client

Use one `mppx` client for native MPP endpoints and standard or route-bound x402 exact endpoints.

### Pay from the CLI

Use the default protocol selection to prefer MPP and fall back to a compatible x402 `exact` offer:

```bash [test.sh]
$ mppx https://api.example.com/paid
```

Pass `--protocol x402` when you need to require the x402 rail. The CLI uses the EVM account selected by `--account`, `MPPX_ACCOUNT`, or `MPPX_PRIVATE_KEY`.

```bash [test.sh]
$ mppx https://api.example.com/paid --protocol x402
```

See the [CLI reference](/sdk/typescript/cli) for account and request options.

### Build a client for MPP and x402

### Direct

Create a server-only wallet.ts module, then import account wherever an example creates a local signing account.

```ts
import { privateKeyToAccount } from 'viem/accounts'

export const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
```

### Privy

Create an EVM wallet in Privy, fund it with the required currency on this page's network, and keep PRIVY\_APP\_SECRET server-side.

```bash
pnpm add @privy-io/node
```

Create a server-only privy.ts module, then import its account wherever an example configures account or feePayer.

```ts
import { PrivyClient } from '@privy-io/node'
import { createViemAccount } from '@privy-io/node/viem'

const privy = new PrivyClient({
  appId: process.env.PRIVY_APP_ID!,
  appSecret: process.env.PRIVY_APP_SECRET!,
})

export const account = createViemAccount(privy, {
  address: process.env.PRIVY_WALLET_ADDRESS as `0x${string}`,
  walletId: process.env.PRIVY_WALLET_ID!,
})
```

createViemAccount delegates signatures to the Privy wallet, so it replaces any local viem account in the examples on this page.

Start with an existing x402 fetch client:

```ts [client.ts]
import { x402Client } from '@x402/core/client'
import { ExactEvmScheme } from '@x402/evm/exact/client'
import { wrapFetchWithPayment } from '@x402/fetch'
import { privateKeyToAccount } from 'viem/accounts'

const account = privateKeyToAccount(
  '0x0123456789012345678901234567890123456789012345678901234567890123',
)

const client = new x402Client()
client.register('eip155:*', new ExactEvmScheme(account))

const fetchWithPayment = wrapFetchWithPayment(fetch, client)
const response = await fetchWithPayment('https://api.example.com/paid')

console.log(response.status)
// @log: 200
```

Replace the x402 wrapper with `Fetch.from`, register the same EVM account and asset policy, then add the MPP methods you want to support:

```ts twoslash [client.ts]
import { Fetch, evm, tempo } from 'mppx/client'
import { privateKeyToAccount } from 'viem/accounts'

const account = privateKeyToAccount(
  '0x0123456789012345678901234567890123456789012345678901234567890123',
)

const fetch = Fetch.from({ // [!code hl]
  acceptPaymentPolicy: {
    origins: ['https://api.example.com'],
  },
  methods: [
    evm.charge({
      account,
      currencies: [evm.assets.baseSepolia.USDC],
      maxAmount: '1.00',
    }),
    tempo.charge({ account }),
  ],
})

const response = await fetch('https://api.example.com/paid')
console.log(response.status)
// @log: 200
```

The same client now reads native MPP and x402 Challenges, then retries with the matching Credential header. It accepts an advertised resource URL that differs from the final response URL, then validates the EIP-3009 token metadata, network, currency, and amount before signing an x402 offer.

### Control the x402 retry

Use `Mppx.create` when you need to inspect a selected x402 Challenge before signing. `preparePayment` selects the offer, and `setCredential` attaches the Credential as `PAYMENT-SIGNATURE`.

```ts twoslash [client.ts]
import { Mppx, evm } from 'mppx/client'
import { privateKeyToAccount } from 'viem/accounts'

const account = privateKeyToAccount(
  '0x0123456789012345678901234567890123456789012345678901234567890123',
)

const mppx = Mppx.create({
  methods: [
    evm.charge({
      account,
      currencies: [evm.assets.baseSepolia.USDC],
      maxAmount: '1.00',
    }),
  ],
  polyfill: false,
})

const request: RequestInit = {}
const challengeResponse = await mppx.rawFetch(
  'https://api.example.com/paid',
  request,
)
if (challengeResponse.status !== 402) throw new Error('Expected payment Challenge')

const payment = await mppx.preparePayment(challengeResponse, { request })
console.log(payment.challenge.request.amount)

const credential = await payment.createCredential()
const paidRequest = payment.setCredential(request, credential)
const response = await mppx.rawFetch(
  'https://api.example.com/paid',
  paidRequest,
)

console.log(response.status)
// @log: 200
```

## Get paid on Tempo with the Tempo facilitator

Keep selling over x402 and get paid on Tempo. Point your x402 middleware at the Tempo facilitator: buyers pay USDC on Base as usual, and each payment arrives as OUSD at your Tempo address.

* No change for buyers: any x402 client pays, such as `@x402/fetch` or `mppx`
* No registration: an API key and a payout address in `extra.tempoSettlement` are all you need
* Already accept MPP on Tempo? You're paid on Tempo directly and don't need it
* Prefer another facilitator? See the [x402 facilitator list](https://docs.x402.org/dev-tools/facilitators) and [x402scan](https://www.x402scan.com/facilitators)

```mermaid
sequenceDiagram
  participant Buyer
  participant Seller
  participant Tempo as Tempo facilitator
  Buyer->>Seller: (1) GET /resource
  Seller-->>Buyer: (2) 402 Payment Required
  Buyer->>Seller: (3) Retry with signed USDC
  Seller->>Tempo: (4) Verify and settle
  Note over Tempo: (5) Settle USDC on Base, send OUSD on Tempo
  Tempo-->>Seller: (6) Base and Tempo hashes
  Seller-->>Buyer: (7) 200 OK

```

### Supported payment networks

| Direction | Network | Chain ID | Token | Schemes |
| --- | --- | --- | --- | --- |
| Pay in | Base mainnet | `eip155:8453` | [USDC](https://basescan.org/token/0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) | `exact` (EIP-3009 or Permit2) |
| Pay out | Tempo mainnet | `eip155:4217` | [OUSD](https://explore.tempo.xyz/address/0x20c0000000000000000000006a37da5c996874be) | — |

Testnet: use `https://api.tempo-dev.workers.dev/v1/x402` with a sandbox key (Base Sepolia USDC in, Moderato OUSD out).

### Set up the facilitator

1. Create a [Tempo API](https://tempo.xyz/developers/docs/api/mpp) key with the `mpp:write` scope, and keep it on your server
2. Point your middleware at `https://api.tempo.xyz/v1/x402` with the key, pay to Tempo's deposit address, and name your payout address in `extra.tempoSettlement`

```bash [test.sh]
$ export TEMPO_API_KEY="tempo:sk:..."
$ export TEMPO_PAYOUT_ADDRESS="0x..." # any Tempo address you control
$ export MPP_SECRET_KEY=$(openssl rand -hex 32) # mppx and pympp only
```

### x402 SDK

### Next.js

:::code-group
```bash [npm]
$ npm install @x402/core @x402/evm @x402/next
```

```bash [pnpm]
$ pnpm add @x402/core @x402/evm @x402/next
```

```bash [bun]
$ bun add @x402/core @x402/evm @x402/next
```
:::

### Hono

:::code-group
```bash [npm]
$ npm install @x402/core @x402/evm @x402/hono hono
```

```bash [pnpm]
$ pnpm add @x402/core @x402/evm @x402/hono hono
```

```bash [bun]
$ bun add @x402/core @x402/evm @x402/hono hono
```
:::

### Express

:::code-group
```bash [npm]
$ npm install @x402/core @x402/evm @x402/express express
```

```bash [pnpm]
$ pnpm add @x402/core @x402/evm @x402/express express
```

```bash [bun]
$ bun add @x402/core @x402/evm @x402/express express
```
:::

:::code-group
```ts [Next.js]
import { HTTPFacilitatorClient, x402ResourceServer } from '@x402/core/server'
import { ExactEvmScheme } from '@x402/evm/exact/server'
import { withX402 } from '@x402/next'
import { NextResponse } from 'next/server'

const network = 'eip155:8453' // Base mainnet
// [!code hl:start]
const headers = { 'tempo-api-key': process.env.TEMPO_API_KEY! }

const facilitator = new HTTPFacilitatorClient({
  createAuthHeaders: async () => ({ settle: headers, verify: headers }),
  url: 'https://api.tempo.xyz/v1/x402',
})
// [!code hl:end]

const server = new x402ResourceServer(facilitator).register(network, new ExactEvmScheme())

// Tempo's deposit address on Base, read from GET /supported when the middleware starts
const payTo = () => server.getSupportedKind(2, network, 'exact')?.extra?.payTo as string // [!code hl]

export const GET = withX402(
  async () => NextResponse.json({ data: 'premium content' }),
  {
    accepts: {
      extra: { tempoSettlement: process.env.TEMPO_PAYOUT_ADDRESS! }, // [!code hl]
      network,
      payTo,
      price: '$0.01',
      scheme: 'exact',
    },
  },
  server,
)
```

```ts [Hono]
import { HTTPFacilitatorClient, x402ResourceServer } from '@x402/core/server'
import { ExactEvmScheme } from '@x402/evm/exact/server'
import { paymentMiddleware } from '@x402/hono'
import { Hono } from 'hono'

const network = 'eip155:8453' // Base mainnet
// [!code hl:start]
const headers = { 'tempo-api-key': process.env.TEMPO_API_KEY! }

const facilitator = new HTTPFacilitatorClient({
  createAuthHeaders: async () => ({ settle: headers, verify: headers }),
  url: 'https://api.tempo.xyz/v1/x402',
})
// [!code hl:end]

const server = new x402ResourceServer(facilitator).register(network, new ExactEvmScheme())

// Tempo's deposit address on Base, read from GET /supported when the middleware starts
const payTo = () => server.getSupportedKind(2, network, 'exact')?.extra?.payTo as string // [!code hl]

const app = new Hono()

app.use(
  paymentMiddleware(
    {
      'GET /api/data': {
        accepts: {
          extra: { tempoSettlement: process.env.TEMPO_PAYOUT_ADDRESS! }, // [!code hl]
          network,
          payTo,
          price: '$0.01',
          scheme: 'exact',
        },
      },
    },
    server,
  ),
)

app.get('/api/data', (c) => c.json({ data: 'premium content' }))

export default app
```

```ts [Express]
import { HTTPFacilitatorClient, x402ResourceServer } from '@x402/core/server'
import { ExactEvmScheme } from '@x402/evm/exact/server'
import { paymentMiddleware } from '@x402/express'
import express from 'express'

const network = 'eip155:8453' // Base mainnet
// [!code hl:start]
const headers = { 'tempo-api-key': process.env.TEMPO_API_KEY! }

const facilitator = new HTTPFacilitatorClient({
  createAuthHeaders: async () => ({ settle: headers, verify: headers }),
  url: 'https://api.tempo.xyz/v1/x402',
})
// [!code hl:end]

const server = new x402ResourceServer(facilitator).register(network, new ExactEvmScheme())

// Tempo's deposit address on Base, read from GET /supported when the middleware starts
const payTo = () => server.getSupportedKind(2, network, 'exact')?.extra?.payTo as string // [!code hl]

const app = express()

app.use(
  paymentMiddleware(
    {
      'GET /api/data': {
        accepts: {
          extra: { tempoSettlement: process.env.TEMPO_PAYOUT_ADDRESS! }, // [!code hl]
          network,
          payTo,
          price: '$0.01',
          scheme: 'exact',
        },
      },
    },
    server,
  ),
)

app.get('/api/data', (req, res) => {
  res.json({ data: 'premium content' })
})

app.listen(4021)
```
:::

### mppx

:::code-group
```bash [npm]
$ npm install mppx hono
```

```bash [pnpm]
$ pnpm add mppx hono
```

```bash [bun]
$ bun add mppx hono
```
:::

```ts [server.ts]
import { Hono } from 'hono'
import { Mppx, evm } from 'mppx/hono'

const facilitator = 'https://api.tempo.xyz/v1/x402'

const mppx = Mppx.create({
  methods: [
    evm.charge({
      currency: evm.assets.base.USDC,
      // [!code hl:start]
      recipient: await evm.facilitatorPayTo(facilitator, { network: 'eip155:8453' }),
      x402: {
        extra: { tempoSettlement: process.env.TEMPO_PAYOUT_ADDRESS! },
        facilitator,
        headers: { 'tempo-api-key': process.env.TEMPO_API_KEY! },
        routeBinding: 'resource', // accept any x402 client
      },
      // [!code hl:end]
    }),
  ],
})

const app = new Hono()

app.get('/api/data', mppx.evm.charge({ amount: '0.01' }), (c) => c.json({ data: 'premium content' }))

export default app
```

### Python

```bash [test.sh]
$ pip install "pympp[x402]" uvicorn
$ export TEMPO_DEPOSIT_ADDRESS=$(curl -s https://api.tempo.xyz/v1/x402/supported \
  | jq -r '[.kinds[] | select(.network == "eip155:8453")][0].extra.payTo')
```

```python [main.py]
import os

from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse

from mpp import Credential, Receipt
from mpp.methods.evm import BASE_USDC
from mpp.methods.evm import server as evm
from mpp.server import Mpp, pay
from mpp.x402 import HttpFacilitator

# [!code hl:start]
facilitator = HttpFacilitator(
    "https://api.tempo.xyz/v1/x402",
    headers={"tempo-api-key": os.environ["TEMPO_API_KEY"]},
)
# [!code hl:end]

mpp = Mpp(
    methods=evm.charge(
        currency=BASE_USDC,
        # [!code hl:start]
        recipient=os.environ["TEMPO_DEPOSIT_ADDRESS"],  # payTo from /supported
        facilitator=facilitator,
        x402_extra={"tempoSettlement": os.environ["TEMPO_PAYOUT_ADDRESS"]},
        route_binding="resource",  # accept any x402 client
        # [!code hl:end]
    ),
)

app = FastAPI()


@app.get("/api/data")
@pay(mpp.charge(amount="0.01"))
async def data(request: Request, credential: Credential, receipt: Receipt) -> JSONResponse:
    return JSONResponse({"data": "premium content"})
```

* `payTo` is Tempo's deposit address on Base, from the public `GET /v1/x402/supported`
* `mppx` and `pympp` need `routeBinding: 'resource'` (`route_binding="resource"`) to accept buyers that use the x402 SDK

### Check the payout

Settle waits for the Base receipt, then returns the Base hash in `transaction` and the Tempo payout in `extensions.tempoSettlement`:

```json
{
  "success": true,
  "transaction": "0x<BASE_HASH>",
  "network": "eip155:8453",
  "extensions": {
    "tempoSettlement": {
      "status": "pending",
      "amount": "10000",
      "to": "<TEMPO_PAYOUT_ADDRESS>",
      "payoutId": "x402pay_..."
    }
  }
}
```

The OUSD arrives a few minutes later, once Base is final: poll `GET /v1/x402/payouts/{payoutId}` until `status` is `confirmed`.

### Facilitator reference

All routes live under `https://api.tempo.xyz/v1/x402`. Send the API key in the `tempo-api-key` header.

| Route | Auth | Purpose |
|---|---|---|
| `GET /supported` | Public | Networks and the deposit address (`extra.payTo`) |
| `POST /verify` | `mpp:write` | Checks a payment without settling it |
| `POST /settle` | `mpp:write` | Settles on Base and sends the Tempo payout |
| `GET /payouts/{id}` | `mpp:write` | Payout status: `pending`, `submitted`, `confirmed`, or `failed` |
| `GET /settlements/{transaction}` | `mpp:write` | The same payout, by its Base hash |

Verify and settle answer HTTP `200` with `isValid: false` or `success: false` and a reason:

| Reason | Fix |
|---|---|
| `payto_not_deposit_address` | Pay to `extra.payTo` from `/supported` |
| `missing_tempo_settlement` | Set `extra.tempoSettlement` to a valid Tempo address |
| `amount_above_maximum` | Lower the route's price |
| `settlement_pending` | Retry settle with the same payload; buyers resend the same signed payment. It never pays twice |
| HTTP `429` | Settle is rate-limited per API key; retry after `Retry-After` |

## Next steps

[Charge per request](/guides/one-time-payments) — One payment per request, settled on-chain

[Payment Methods](/payment-methods) — Method-specific request schemas

[Server quickstart](/quickstart/server) — Charge for your API as a seller
