# Backend Integration

In production, the `CityFundClient` should live on your backend rather than in browser code. A thin server route keeps your API key private and gives you a natural hook for policy enforcement.

```
// server/fund.ts
import { CityFundClient } from "@cityprotocol/core";

const fundClient = new CityFundClient({
  apiKey: process.env.FUN_API_KEY!,
});

export async function handleDepositRequest(walletAddress: string, userId: string) {
  // 1. Run compliance checks against userId / walletAddress
  // 2. Enforce allowed-asset policy (e.g. stablecoins only)

  const uda = await fundClient.getUdaAddress({
    recipientAddr: walletAddress,
    userId: userId,
    network: "56",
    toNetwork: "56",
    toTokenAddress: "0x55d398326f99059fF775485246999027B3197955",
  });

  // 3. Log to your audit trail / reconciliation table
  return uda;
}
```

This pattern enables several production-grade capabilities:&#x20;

1. **allowed-asset policy** to restrict which tokens and networks your users can fund with,&#x20;
2. **compliance checks** to screen wallet addresses or user identities before generating a deposit address,&#x20;
3. **audit trails** to log every UDA generation event for internal reporting,&#x20;
4. **user mapping and reconciliation** to tie each deposit address back to your internal user records for downstream accounting.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://city-protocol.gitbook.io/docs/software-development-kit/deposit-add-fund/backend-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
