> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monad.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# MPP API Reference

> Reference for the @monad-crypto/mpp package

This page is a technical reference for `@monad-crypto/mpp`. For a developer-oriented guide with examples, visit the [overview](/reference/mpp/overview).

## Server

### Example

```ts title="server.ts" highlight={9-13} theme={null}
import { monad } from "@monad-crypto/mpp/server";
import { Mppx } from "mppx";
import { privateKeyToAccount } from "viem/accounts";

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

const mppx = Mppx.create({
  methods: [
    monad({
      account,
      recipient: account.address,
      // ... parameters below
    }),
  ],
});
```

### Parameters

The `monad` server payment method accepts the following parameters.

| Parameter             | Type                                       | Default | Description                                                                                                                                                        |
| --------------------- | ------------------------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `amount`              | `string`                                   | —       | Default payment amount, human-readable (e.g. `"1.50"`)                                                                                                             |
| `currency`            | `string`                                   | USDC    | ERC-20 token contract address                                                                                                                                      |
| `decimals`            | `number`                                   | `6`     | Token decimals                                                                                                                                                     |
| `description`         | `string`                                   | —       | Human-readable description                                                                                                                                         |
| `externalId`          | `string`                                   | —       | External identifier to echo back in receipt                                                                                                                        |
| `recipient`           | `string`                                   | —       | Recipient address for payments                                                                                                                                     |
| `testnet`             | `boolean`                                  | `false` | Testnet mode                                                                                                                                                       |
| `waitForConfirmation` | `boolean`                                  | `true`  | Whether to wait for the charge transaction to confirm on-chain                                                                                                     |
| `getClient`           | `(params: { chainId?: number }) => Client` | —       | Function that returns a viem Client for the given chain ID                                                                                                         |
| `account`             | `Account \| Address`                       | —       | Server account used to broadcast `receiveWithAuthorization` transactions. Required when accepting `authorization` payloads. The server pays gas from this account. |
| `store`               | `Store`                                    | —       | Store for transaction hash replay protection. Use a shared store in multi-instance deployments so consumed hashes are visible across all server instances.         |

## Client

### Example

```ts title="client.ts" highlight={8-11} theme={null}
import { monad } from "@monad-crypto/mpp/client";
import { Mppx } from "mppx/client";
import { privateKeyToAccount } from "viem/accounts";

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

const mppx = Mppx.create({
  methods: [monad({ 
    account,
    // ... parameters below
  })],
});

// Make a paid request
const response = await fetch("http://localhost:3000/premium");
const data = await response.json();
console.log(data);
```

### Parameters

The `monad` client payment method accepts the following parameters.

| Parameter   | Type                                       | Default | Description                                                                            |
| ----------- | ------------------------------------------ | ------- | -------------------------------------------------------------------------------------- |
| `account`   | `Account \| Address`                       | —       | Wallet account. If omitted, resolved from the viem Client.                             |
| `mode`      | `"push" \| "pull"`                         | Auto    | Payment mode. Defaults to `"push"` for JSON-RPC accounts, `"pull"` for local accounts. |
| `getClient` | `(params: { chainId?: number }) => Client` | —       | Custom viem Client resolver. Uses built-in RPC URLs if not provided.                   |
