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

# waitForDepositCredit

> Await deposit credit after logDeposit returns handover_pending.

Polls [`getDepositStatus`](/docs/sdk/api/get-deposit-status) until the deposit is credited. Resolves when `status === "credited"` and `balanceCredited === true`. Rejects if custody handover fails (`recovered_to_eoa`), polling errors, or the timeout elapses.

Requires `connectAccount()` on the **same** `ZyfaiSDK` instance.

## Signature

```typescript theme={null}
waitForDepositCredit(
  depositId: string,
  chainId: SupportedChainId,
  options?: WaitForDepositCreditOptions,
): Promise<DepositLifecycleResponse>
```

## Parameters

| Parameter   | Type                          | Required | Description                                                                                               |
| ----------- | ----------------------------- | :------: | --------------------------------------------------------------------------------------------------------- |
| `depositId` | `string`                      |     ✅    | Lifecycle UUID from `logDeposit().deposit.id` or `sendDeposit().registration.id`                          |
| `chainId`   | `SupportedChainId`            |     ✅    | Chain the deposit was registered on (`1`, `8453`, or `42161`) — selects default poll interval and timeout |
| `options`   | `WaitForDepositCreditOptions` |     ❌    | Poll interval and timeout overrides                                                                       |

```typescript theme={null}
interface WaitForDepositCreditOptions {
  intervalMs?: number;  // default: chain-specific (see below)
  timeoutMs?: number;   // default: chain-specific (see below)
}
```

Default polling by chain:

| Chain              | `intervalMs` | `timeoutMs`            |
| ------------------ | ------------ | ---------------------- |
| Ethereum (`1`)     | 2000 ms      | 60000 ms (1 minute)    |
| Base (`8453`)      | 500 ms       | 20000 ms (\~10 blocks) |
| Arbitrum (`42161`) | 250 ms       | 20000 ms (\~10 blocks) |

These are normal user-facing completion windows. Pass a larger `timeoutMs` only
when an integration explicitly wants to wait through the backend recovery path.

## Returns

The final `DepositLifecycleResponse` when `status === "credited"` and `balanceCredited === true`.

## Errors

| Condition                        | Error                                                                               |
| -------------------------------- | ----------------------------------------------------------------------------------- |
| `status === "recovered_to_eoa"`  | `Deposit {id} recovered to EOA (status=recovered_to_eoa); balance was not credited` |
| Timeout (chain-specific default) | `Timed out waiting for deposit {id} to be credited`                                 |
| Poll failure                     | Original error from `getDepositStatus`                                              |

## Example

### After logDeposit

```typescript theme={null}
await sdk.connectAccount(walletProvider, 8453);

const result = await sdk.logDeposit(8453, txHash, "100000000");

if (result.deposit.status === "handover_pending") {
  const credited = await sdk.waitForDepositCredit(result.deposit.id, 8453);
  console.log("Deposit credited:", credited.id);
}
```

### With custom timeout

```typescript theme={null}
const credited = await sdk.waitForDepositCredit(depositId, 1, {
  intervalMs: 3_000,
  timeoutMs: 600_000, // 10 minutes
});
```

## Related methods

* [`getDepositStatus`](/docs/sdk/api/get-deposit-status) — single status fetch
