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

# Install the Avatar SDK

> Install and initialize the Avatar SDK.

Install the package, depending on your package manager:

<Tabs>
  <Tab title="npm">
    ```bash theme={null}
    npm install @thenamespace/avatar
    ```
  </Tab>

  <Tab title="Yarn">
    ```bash theme={null}
    yarn add @thenamespace/avatar
    ```
  </Tab>

  <Tab title="pnpm">
    ```bash theme={null}
    pnpm add @thenamespace/avatar
    ```
  </Tab>
</Tabs>

Initialize the client with your website domain. The domain is required because it is embedded in the SIWE message the user signs:

```typescript theme={null}
import { createAvatarClient } from '@thenamespace/avatar';

const client = createAvatarClient({
  domain: 'myapp.com',
});
```

To target testnet, set `network: 'sepolia'`:

```typescript theme={null}
const client = createAvatarClient({
  domain: 'myapp.com',
  network: 'sepolia',
});
```

For automatic signing, pass a wallet provider directly:

```typescript theme={null}
const client = createAvatarClient({
  domain: 'myapp.com',
  network: 'mainnet',
  provider: walletClient, // Viem WalletClient, Ethers Wallet/Signer, or WalletProvider
});
```

### AvatarSDKConfig

| Parameter  | Default                    | Description                                                             |
| ---------- | -------------------------- | ----------------------------------------------------------------------- |
| `domain`   | —                          | Your website domain. Required for SIWE authentication.                  |
| `network`  | `mainnet`                  | `'mainnet'` or `'sepolia'`.                                             |
| `apiUrl`   | Namespace Metadata Service | Advanced override for the API base URL.                                 |
| `provider` | —                          | Wallet used for automatic signing. Viem, Ethers, or a `WalletProvider`. |

<Note>
  The SDK uses chain ID `1` for mainnet and `11155111` for sepolia when building SIWE messages. Before every automatic operation it compares the provider's chain ID with the configured network and calls `switchChain` when available, otherwise it throws `PROVIDER_CHAIN_MISMATCH`.
</Note>
