> ## 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.

# getNestedSafeOnboardingStatus

Nested-parent onboarding snapshot for a connected parent Safe. Use it after [`connectAccount`](https://docs.zyf.ai/docs/sdk/api/connect-account) to decide which treasury step to show next: child deploy, deposit, or withdraw.

Wallet connect stays in your app (WalletConnect, Reown AppKit, Safe App). This method reads chain state and the execution API. It combines child resolution ([`getSmartWalletAddress`](https://docs.zyf.ai/docs/sdk/api/get-smart-wallet-address)), account session registration, per-chain safe-deploy readiness, and [`getPortfolio`](https://docs.zyf.ai/docs/sdk/api/get-portfolio).

For the full parent-Safe flow, see [Nested Safe integration](https://docs.zyf.ai/docs/sdk/nested-safe-deposit.md).

## Signature

```typescript theme={null}
getNestedSafeOnboardingStatus(
  userAddress: string,
  chainId: SupportedChainId,
): Promise<NestedSafeOnboardingStatusResponse>
```

## Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `userAddress` | `string` | ✅ | Parent Safe address returned from `connectAccount` |
| `chainId` | `SupportedChainId` | ✅ | Chain you are onboarding on (deployment and session are per chain) |

Requires SIWE authentication (`connectAccount`). `userAddress` must match the authenticated wallet.

## Returns

Onboarding flags, suggested next step, and child wallet details when registered.

## Return type

```typescript theme={null}
interface NestedSafeOnboardingStatusResponse {
  success: boolean;
  userAddress: string;
  chainId: number;
  status: NestedSafeOnboardingStatus;
}

interface NestedSafeOnboardingStatus {
  isNestedOwner: boolean;
  childRegistered: boolean;
  childDeployed: boolean;
  sessionActive: boolean;
  hasPortfolioBalance: boolean;
  suggestedStep: NestedSafeOnboardingStep;
  child: SmartWalletResponse | null;
}

type NestedSafeOnboardingStep = "deploy" | "deposit" | "withdraw" | "ready";
```

### Status fields

| Field | Meaning |
| - | - |
| `isNestedOwner` | `userAddress` is a deployed Safe on `chainId` |
| `childRegistered` | Execution API has a child assigned to this parent |
| `childDeployed` | Child Safe has code on `chainId` |
| `sessionActive` | Account session is registered **and** per-chain safe-deploy permissions are ready, with a registered deployed child |
| `hasPortfolioBalance` | Child has idle balances or positions the agent can withdraw |
| `child` | Same shape as `getSmartWalletAddress` when registered; otherwise `null` |

`sessionActive` is scoped to the `chainId` you pass. An account-level session flag alone is not enough: the child can be deployed on Base while Arbitrum still needs a `deploySafe` completion on that chain.

### `suggestedStep`

| Value | When | Typical SDK action |
| - | - | - |
| `deploy` | Not a nested owner, or child missing / not deployed, or session inactive on this chain | [`deploySafe`](https://docs.zyf.ai/docs/sdk/nested-safe-deposit#2-deploy-the-child). The session record is written on the following `sendDeposit`, unless the fourth `deploySafe` argument is `true` |
| `deposit` | Child deployed, session active on this chain, no withdrawable balance | [`sendDeposit`](https://docs.zyf.ai/docs/sdk/api/send-deposit) |
| `withdraw` | Withdrawable portfolio balance | [`withdrawFunds`](https://docs.zyf.ai/docs/sdk/api/withdraw-funds) |

If the child is deployed but the session is inactive on the requested chain, `suggestedStep` is `deploy` (call `deploySafe` again).

The `"ready"` variant exists on the type for forward compatibility; current SDK logic returns `deploy`, `deposit`, or `withdraw`.

## Errors

| Condition | Message |
| - | - |
| Empty `userAddress` | `User address is required` |
| Unsupported `chainId` | `Unsupported chain ID: …` |
| `userAddress` ≠ connected wallet | `userAddress does not match the authenticated wallet` |

## Example

Gate treasury UI after connect and refresh when chain or account changes:

```typescript theme={null}
const parent = await sdk.connectAccount(provider, chainId);

const { status } = await sdk.getNestedSafeOnboardingStatus(parent, chainId);

switch (status.suggestedStep) {
  case "deploy":
    await sdk.deploySafe(parent, chainId);
    break;
  case "deposit":
    await sdk.sendDeposit({
      userAddress: parent,
      chainId,
      amount: "100000000",
      asset: "USDC",
    });
    break;
  case "withdraw":
    await sdk.withdrawFunds(parent, chainId);
    break;
}
```

Working reference UI: [nested Safe demo](https://sdk.demo.zyf.ai/nested-safe).


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