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

# Authenticate with External Wallets

> Let users sign in to your Unity app with wallets they already own, such as MetaMask or Phantom.

External wallets — also called externally owned accounts (EOAs) — are wallets users bring to your app, such as MetaMask, Phantom, or Rainbow. They are different from embedded wallets, which Dynamic creates and manages for the user.

When external wallet login is enabled, users can sign up or log in by connecting an existing wallet through the Dynamic auth UI. The SDK handles the wallet app handoff and returns the connected wallet.

## Prerequisites

* Dynamic Unity SDK initialized (see [Installation Guide](/docs/unity/installation-guide))
* `ClientPropsData` configured with **App Origin**
* A deep link scheme configured in your Unity Player Settings
* Chains enabled in your Dynamic dashboard
* Wallet login enabled under **External Wallets** in the dashboard

## Dashboard configuration

1. Go to **Chains & Networks** in the [Dynamic dashboard](https://app.dynamic.xyz/dashboard/chains-and-networks) and enable the chains you want to support (e.g. EVM, Solana).
2. Go to **Log in & User Profile** in the [Dynamic dashboard](https://app.dynamic.xyz/dashboard/log-in-user-profile) and toggle on **Wallet Log in** under **External Wallets**.
3. Go to **Security → Whitelist Mobile Deeplink** and add your app's redirect URL (e.g. `myapp://`). This is required for the wallet app to return to your app after approval.

<Warning>
  **App Origin** is required for external wallet connections. Set it in the `ClientPropsData` asset to the HTTPS origin that represents your app (for example, `https://your-app.com`).
</Warning>

## SDK configuration

In the Unity Editor, create a `ClientPropsData` asset at **Assets > Create > DynamicSDK > Client Props** and configure it in the Inspector:

| Field              | Value                       |
| ------------------ | --------------------------- |
| **Environment ID** | Your Dynamic environment ID |
| **App Name**       | Your app's display name     |
| **App Logo URL**   | URL to your app logo        |
| **App Origin**     | `https://your-app.com`      |

Initialize the SDK from a `MonoBehaviour` in `Awake`:

```csharp theme={"system"}
using DynamicSDK.Core;
using UnityEngine;

public class DynamicSDKManager : MonoBehaviour
{
    [SerializeField] private ClientPropsData props;

    private void Awake()
    {
        DynamicSDK.DynamicSDK.Init(props);
    }
}
```

## Deep link setup

External wallet connections open the wallet app using deep links. The wallet app then redirects back to your app using the URL scheme you configured.

Configure your app's deep link scheme in the Unity Player Settings for iOS and Android. The scheme must match the redirect URL whitelisted in the Dynamic dashboard (for example, `myapp://`).

## Show the auth UI

The simplest way to let users connect an external wallet is to show the Dynamic auth UI. The SDK presents available wallet options, opens the selected wallet app, and handles the redirect automatically.

```csharp theme={"system"}
DynamicSDK.Instance.UI.ShowAuth();
```

## Listen for connected wallets

After a wallet is connected, it appears in the user's wallet list. Subscribe to `OnUserWalletsChanged` and read `UserWallets` to react to new or updated wallets:

```csharp theme={"system"}
using DynamicSDK.Core;
using UnityEngine;
using System.Collections.Generic;

public class WalletListener : MonoBehaviour
{
    private void Start()
    {
        DynamicSDK.Instance.Wallets.OnUserWalletsChanged += OnWalletsChanged;

        // Check for any wallets already connected
        DisplayWallets(DynamicSDK.Instance.Wallets.UserWallets);
    }

    private void OnWalletsChanged(List<BaseWallet> wallets)
    {
        DisplayWallets(wallets);
    }

    private void DisplayWallets(List<BaseWallet> wallets)
    {
        foreach (var wallet in wallets)
        {
            Debug.Log($"Wallet: {wallet.Address} ({wallet.Chain})");
        }
    }
}
```

## Filter connected wallets

You can separate EVM and Solana wallets by chain:

```csharp theme={"system"}
List<BaseWallet> wallets = DynamicSDK.Instance.Wallets.UserWallets;
List<BaseWallet> evmWallets = wallets.FindAll(w => w.Chain.ToUpper() == "EVM");
List<BaseWallet> solanaWallets = wallets.FindAll(w => w.Chain.ToUpper() == "SOL");
```

## Set the primary wallet

If a user connects multiple wallets, you can set one as the primary wallet:

```csharp theme={"system"}
using DynamicSDK.Core;
using UnityEngine;

public class WalletManager : MonoBehaviour
{
    public async void SetPrimaryWallet(BaseWallet wallet)
    {
        try
        {
            await DynamicSDK.Instance.Wallets.SetPrimary(wallet.Id);
        }
        catch (System.Exception e)
        {
            Debug.LogError($"Failed to set primary wallet: {e.Message}");
        }
    }
}
```

## Troubleshooting

* **Wallet app does not open**: Verify your app's URL scheme is configured in the Unity Player Settings and matches the redirect URL whitelisted in the dashboard.
* **Wallet does not appear after connection**: Ensure you are subscribed to `OnUserWalletsChanged` and checking `UserWallets`.
* **Connection fails after redirect**: Confirm **App Origin** is set in `ClientPropsData` and matches the origin registered in the dashboard.

## Next steps

* [Wallet Creation](/docs/unity/wallet-creation) for embedded wallets
* [SDK Reference](/docs/unity/sdk-reference/overview)
* [Token Balances](/docs/unity/wallets/general/token-balances)
