> ## Documentation Index
> Fetch the complete documentation index at: https://rain-sandbox-trial.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Fund the Wallet

> Read a user's collateral contract and confirm their card's spending power after funding it on-chain.

Once the user is [approved](/sdks/embedded-wallets-onboarding), fund their card **spending power** by moving supported tokens (for example USDC or USDT) on-chain.

<Warning>
  The embedded wallet can hold funds, but wallet balances do not fund card spend on their own. Card spend is backed by the user's Rain **collateral**, not by whatever sits in the wallet. Fund spending power one of two ways, depending on your program's collateral configuration:

  * The user deposits tokens into their Rain **collateral contract**.
  * If your program uses **[Real Time Funding](/docs/real-time-funding)**, Rain pulls from the wallet at authorization instead.

  See [Managing Collateral](/docs/managing-collateral) and [Supported Chains & Tokens](/docs/supported-chains-and-tokens).
</Warning>

This page covers **Rain-managed** embedded-wallet programs. Partner-managed programs fund a shared collateral account from the dashboard instead. See [Partner-managed programs](/docs/partner-managed-programs).

## Read the user's collateral details

Rain assigns a collateral contract when the user is approved. Read it to get the chain and, for programs that use one, the destination address for funding. From your backend, use the server-side SDK (API key):

```ts theme={null}
const contracts = await client.users.retrieveContracts(userId);
```

Or fetch it directly in your app with the Client SDK's [built-in Rain API client](/sdks/embedded-wallets-authentication#built-in-rain-api-client), which mints and caches the required session token itself:

<CodeGroup>
  ```swift iOS theme={null}
  let contracts: [RainCollateralContract] = try await rain.fetchCollateralContracts()
  let contract = try await rain.fetchCollateralContract()   // first contract; throws RAIN_304 if none
  ```

  ```kotlin Android theme={null}
  val contracts: List<RainCollateralContract> = rain.fetchCollateralContracts()
  val contract = rain.fetchCollateralContract()   // first contract; throws RAIN_304 if none
  ```
</CodeGroup>

Each `RainCollateralContract` contains:

| Field               | Type                    | Description                                                                                               |
| ------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------- |
| `id`                | `String?`               | Contract id                                                                                               |
| `chainId`           | `Int`                   | Chain the contract lives on                                                                               |
| `proxyAddress`      | `String`                | Collateral proxy address                                                                                  |
| `controllerAddress` | `String`                | Collateral controller address                                                                             |
| `depositAddress`    | `String?`               | Funding destination, for programs that use one                                                            |
| `adminAddresses`    | `[String]`              | Wallets authorized to sign withdrawals                                                                    |
| `contractVersion`   | `Int?`                  | Contract version                                                                                          |
| `tokens`            | `[RainCollateralToken]` | Per-token balances (`address`, `balance`, `exchangeRate`, `advanceRate`, `name?`, `symbol?`, `decimals?`) |

Token `name` / `symbol` / `decimals` are enriched best-effort from the token registry or an on-chain read; a failed lookup leaves them empty rather than fabricating values. See [Managing Collateral](/docs/managing-collateral).

## Move funds from the wallet

Move tokens out of the embedded wallet with the SDK's [send methods](/sdks/embedded-wallets-balances-and-transactions#send-tokens): an ordinary on-chain transfer to the collateral destination your program uses. Rain detects the transfer and updates the user's spending power automatically. (Programs using [Real Time Funding](/docs/real-time-funding) skip this deposit; the user keeps funds in the wallet and grants an allowance instead.)

<Info>
  In sandbox, mint rUSD test tokens to fund collateral. See [Mint Test Tokens](/docs/sandbox-mint-test-tokens-for-collateral).
</Info>

## Verify spending power

Confirm the funds registered by reading the user's Rain balances (in cents):

```bash theme={null}
curl "https://api-dev.rain.xyz/v1/issuing/users/{userId}/balances" \
     -H "Api-Key: <YOUR_API_KEY>"
# creditLimit, spendingPower, balanceDue, pendingCharges, postedCharges
```

Callable from your backend, or your app with a CST. Once `spendingPower` is greater than zero, the user's card can transact.

## What's next

<Columns cols={3}>
  <Card title="Card Issuance" icon="credit-card" href="/sdks/card-issuance">
    Issue a card the user can spend.
  </Card>

  <Card title="Balances & Transactions" icon="coins" href="/sdks/embedded-wallets-balances-and-transactions">
    Read wallet balances and send tokens.
  </Card>

  <Card title="Withdraw Collateral" icon="arrow-right-from-bracket" href="/sdks/embedded-wallets-withdraw-collateral">
    Withdraw funds back out later.
  </Card>
</Columns>
