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

# Per-customer deposit addresses

> One standing deposit address per registered customer, issued by your backend and verified in the browser. Opt-in, testnet.

> [!NOTE]
>
> **Testnet, opt-in.** Issuance is on for **Base Sepolia** (`84532`) and **Ethereum Sepolia** (`11155111`). Other networks answer `rail3_not_available_on_chain` or `token_not_watched_on_chain`, and TRON is refused. Nothing here runs on a mainnet. [Roadmap](https://docs.cryptocheckout.ai/reference/roadmap.md).

A third way to get paid, beside [connect and deposit](https://docs.cryptocheckout.ai/concepts/payment-rails.md). Instead of one address per invoice, a customer you already know gets one address per network and token, and keeps it. Every deposit to it lands in the same pool as your other payments.

It suits **account-based** businesses: balance top-ups, subscriptions, marketplaces, B2B accounts. The address identifies *who* paid, not *which order*, so it is the wrong tool for one-shot e-commerce checkout. Use the [embedded checkout](https://docs.cryptocheckout.ai/integration/embed.md) there.

## What you need first

* **A customer you already know.** You ask for the address when the customer signs up or opens a funding page, not at checkout. A reference to that customer has to exist before the first deposit.
* **A deployed pool** on that network, the same one your other payments go to. Without it the call answers `409 pool_not_deployed`.
* **Your API key** (`sk_live_…`), on your server. Never in a page.

## How it fits together

```mermaid theme={null}
sequenceDiagram
    participant P as Your page (SDK)
    participant B as Your backend
    participant A as POST /customer-address
    participant V as Verifier frame (our origin)
    participant C as Chain
    P->>B: { chainId, token, customerRef }
    B->>A: same body + X-Api-Key: sk_live_…
    A-->>B: { address, binding }
    B-->>P: the response, unchanged
    P->>V: response + your settlementAnchor
    V->>C: MerchantRegistry.effectiveRecipient(anchor)
    V-->>P: verified / unverified / mismatch / unavailable
```

The response is an **untrusted hint**, exactly like the address the checkout shows. Before the SDK hands you an address, a frame on our origin re-derives it from the chain: the pool from the payout wallet you pinned, then the address from that pool, the token, the two committed fee terms and the contract code this SDK release pins. If any part disagrees, you get no address. [Verification](https://docs.cryptocheckout.ai/concepts/verification.md).

## Step 1 — a route on your backend

The endpoint needs your secret key, so the browser can't call it. Add one route that forwards the body and returns the response unchanged:

```javascript theme={null}
// Express. Your own session decides who the customer is.
app.post("/api/cc/customer-address", requireLogin, async (req, res) => {
  const r = await fetch(`${process.env.CC_API_BASE}/customer-address`, {
    method: "POST",
    headers: { "Content-Type": "application/json", "X-Api-Key": process.env.CC_API_KEY },
    body: JSON.stringify({
      chainId: req.body.chainId,
      token: req.body.token,
      customerRef: refForUser(req.user), // from YOUR session, not from the page
    }),
  });
  res.status(r.status).json(await r.json());
});
```

> [!TIP]
>
> Set `customerRef` from your own session, as above. If you pass on what the page sent, one customer can ask for another customer's address. They gain nothing from it, because money sent there is credited to the other customer, but it is a support ticket you don't need.

## Step 2 — call the SDK from the page

```html theme={null}
<script src="https://www.cryptocheckout.ai/sdk/1.5.0/sdk.js"
        integrity="sha384-XpqfTiIhQVsWxi0+W+zOpXiApjtZ1g6vPdancAUTlPL9MtsbJFV2xa0ItqoII+OO"
        crossorigin="anonymous"></script>
<script>
  CryptoCheckout.customerDeposit({
    customerRef: "cus_7f3a9c",
    chain: 84532,
    token: "USDC",
    endpoint: "/api/cc/customer-address",
    settlementAnchor: "0xYourPayoutWalletAddress",
  }).then(
    (r) => showDepositAddress(r.address, r.verification),
    (err) => showUnavailable(err.code),
  );
</script>
```

`customerDeposit` needs SDK **1.5.0** or later.

## `CryptoCheckout.customerDeposit(options)`

Returns a promise. No other option is accepted. A key that looks like an identity (`email`, `user…`, `player…`, `name`, `phone`, `dob`, …) is refused by name, and any other unknown key is refused too.

**customerRef** `string` *required*

An **opaque** reference to your customer: your internal id, a UUID, or a hash you compute. A sequential number is fine. 1 to 256 UTF-8 bytes, no control characters.

Never send an email address, a phone number or a name. The SDK refuses a value shaped like an e-mail address or a phone number (`identity_value_rejected`) before anything leaves the page. The server never stores the reference itself: it keeps only a keyed hash, scoped to the network and token. [What we store](#what-we-store-and-what-we-dont).

**chain** `number` *required*

The chain ID, for example `84532`.

**token** `string` *required*

A token symbol (`USDC`) or a token address. It has to be one you accept on that network.

**endpoint** `string` *required*

Your backend route from Step 1. The SDK `POST`s `{ chainId, token, customerRef }` to it, with same-origin credentials.

**settlementAnchor** `string`

Your payout wallet, the same pin you give `init()`. With it the address is verified against the chain. Without it the SDK only checks that the response agrees with itself, and resolves with `verification: "unverified"`. Strongly recommended.

**headers** `object`

Extra request headers for your endpoint, for example a CSRF token. `X-Api-Key` is refused.

**timeoutMs** `number` (default: 20000)

How long to wait for the verification before giving up with `verification_unavailable`.

> [!WARNING]
>
> Anything that starts with `sk_live_` or `sk_test_` anywhere in the options is refused with `secret_key_in_browser`. If you see that error, the key is already in your page source. Rotate it.

### Result

**address** `string`

The deposit address, re-derived in the browser (EIP-55 checksummed). Show this one.

**verification** `"verified" | "unverified"`

`verified`: anchored to your on-chain payout attestation. `unverified`: you pinned no anchor, so the address agrees with its own binding but is not anchored to the chain. Show a notice, as the checkout does.

**chainId** `number`

**token** `\{ symbol, address, decimals \}`

**deployed** `boolean`

Whether the address already has code. It doesn't need to: the first deposit can arrive before it is deployed.

**reused** `boolean`

`true` when this customer already had an address on this network and token for your current pool. The call is idempotent: the same customer gets the same address back.

### Errors

The promise rejects with an `Error` whose `code` says why, and whose `retryable` says whether trying again can help.

| `code` | Meaning | What to do |
| - | - | - |
| `destination_mismatch` | The address does not match your on-chain configuration. `reason` names the part: `pool_mismatch`, `address_mismatch`, `implementation_mismatch`, … | **Never show an address.** Treat it like `pool.tamper_suspected` and contact support. Not retryable. |
| `verification_unavailable` | The chain could not be read, or this SDK release has no pinned contract for the network. | Retry later. Never fall back to showing the unverified response. |
| `identity_field_rejected`, `identity_value_rejected`, `unknown_field`, `invalid_customer_ref`, `customer_ref_required`, `invalid_chain`, `invalid_token`, `invalid_settlement_anchor`, `endpoint_required`, `secret_key_in_browser` | Refused in the page. Nothing was sent. | Fix the call. |
| `network_error`, `invalid_response` | Your endpoint could not be reached, or did not return JSON. | Check your route. |
| Any API code | Your endpoint returned the API's error unchanged. `status` carries the HTTP status. On `rate_limited`, `retryAfterSeconds` is set. | See [the API reference](https://docs.cryptocheckout.ai/api/customer-address.md#errors). |

## Fees

You pay the network fee on this rail, not your customer: every deposit is credited at its full amount. The address commits to two fee terms when it is created, both in the token's base units:

* `firstSurcharge` covers creating the address and its first sweep. It is taken once, at the first sweep.
* `surchargePerSweep` covers every later sweep.

Each take is capped in the contract at **10%** of the balance being swept. Both terms are fixed at issuance and never change for that address. If network fees are unusually high when you ask, the call refuses with `422 surcharge_above_ceiling` rather than fixing a high fee into the address for good. Try again later.

On a network where cryptocheckout covers the network fee (every test network today), a new address commits **zero** for both terms and we pay every sweep. Because anyone can send a permanent address a few cents, a covered address is swept only once what waits there reaches a minimum: **0.10** of the token on a test network. Below that it waits, the dashboard says so, and a sweep request is refused with `409 below_sponsored_sweep_floor`. The money can only ever go to your pool, so waiting loses nothing.

The platform fee is the same as on the other rails, taken when the pool distributes. [Fees](https://docs.cryptocheckout.ai/concepts/fees.md).

## When the money reaches your pool

A deposit is **captured at the address** as soon as it reaches that network's confirmation depth. Depth scales with value, and nothing counts at first sight. The [`customer.deposit.confirmed`](https://docs.cryptocheckout.ai/webhooks/events#per-customer-deposits) webhook fires once per deposit, and it is your trigger to credit the customer's balance. From that point the money can only go to your pool.

The sweep into your pool is batched, so it isn't immediate. An address is swept when one of these is true:

* the sweep's network fee is at most **2%** of the address's balance,
* its oldest unswept deposit is **7 days** old,
* or you asked for a sweep.

On an address with no network fee (a covered network), all three wait for the minimum above.

Until then the money waits at the address. It is committed to your pool, but you can't spend it yet.

## What we store, and what we don't

* **No identity.** There is no column for an e-mail, a name or a player id. We never store your `customerRef`, only a keyed hash, scoped to the network and token so one customer's addresses can't be linked across networks through it.
* **The address is public.** Like any blockchain address, it and every deposit to it can be seen by anyone. Whoever holds your mapping from addresses to customers can read a customer's whole deposit history. Keyed derivation stops us and third parties from guessing addresses. It does not hide an address from someone who already knows it.
* **Retention.** We keep each address's deposit history (amounts and times) for 90 days after the webhook for that deposit is delivered.

## Things to know

* **Matching is by customer.** A deposit tells you who paid, not which order. If you sell one-off items, match by amount and time yourself, or use the checkout.
* **Moving your pool retires addresses.** If your payout configuration changes and you get a new pool, addresses issued for the old pool are retired. They are still watched and swept into the pool they were made for. Ask again and the customer gets a new address for the current pool. The webhook says `retired: true` for a deposit to an old one.
* **Payer screening set to Enforce** refuses issuance (`409 rail3_unavailable_with_enforce_screening`): this rail has nowhere to screen a sender before capture yet.
* **Content Security Policy.** The verification runs in a hidden frame from `https://www.cryptocheckout.ai`, so your `frame-src` has to allow it, just as for the checkout. [Embed → CSP](https://docs.cryptocheckout.ai/integration/embed.md#content-security-policy).
* **Server-side only?** Call [`POST /customer-address`](https://docs.cryptocheckout.ai/api/customer-address) directly. You then skip the browser verification, so the address you get is only as trustworthy as the response.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.