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

# createWithViewerKey

> Create an authenticated wallet viewer using a mnemonic or seed.

Creates a `SparkReadonlyClient` authenticated with an identity key derived from a mnemonic or seed. Can query a private wallet as its owner or as the viewer identity authorized by that owner.

Use a separate viewer mnemonic for services. Derive the public key with `deriveViewerIdentityPublicKey(config, mnemonicOrSeed, accountNumber)` and have the owner authorize it with [`setViewerIdentityPublicKey()`](/api-reference/wallet/set-viewer-identity-public-key). Use the same network and account number for derivation and authentication. See the [complete setup](/wallets/privacy#grant-a-service-read-access).

## Method Signature

```typescript theme={null}
static async createWithViewerKey(
  config: ConfigOptions | undefined,
  mnemonicOrSeed: Uint8Array | string,
  accountNumber?: number,
): Promise<SparkReadonlyClient>
```

## Parameters

<ResponseField name="config" type="ConfigOptions | undefined" required>
  Configuration options including network selection. Pass `undefined` for defaults.
</ResponseField>

<ResponseField name="mnemonicOrSeed" type="Uint8Array | string" required>
  BIP-39 mnemonic phrase, hex-encoded seed string, or raw seed bytes.
</ResponseField>

<ResponseField name="accountNumber" type="number">
  Account index for key derivation. Defaults to `0` for REGTEST, `1` otherwise.
</ResponseField>

## Returns

<ResponseField name="client" type="Promise<SparkReadonlyClient>" required>
  An authenticated wallet viewer. Requests include an identity key signature for access to private wallet data.
</ResponseField>

## Example

<CodeGroup>
  ```typescript From Mnemonic theme={null}
  import { SparkReadonlyClient } from "@buildonspark/spark-sdk";

  const client = await SparkReadonlyClient.createWithViewerKey(
    { network: "MAINNET" },
    viewerMnemonic, // The service’s own mnemonic, not the owner’s wallet mnemonic
  );

  // Query a wallet that granted this identity read access.
  const balance = await client.getAvailableBalance("sp1...");
  ```

  ```typescript From Seed theme={null}
  import { SparkReadonlyClient } from "@buildonspark/spark-sdk";

  const client = await SparkReadonlyClient.createWithViewerKey(
    { network: "MAINNET" },
    seedBytes, // Uint8Array
    1,         // account number
  );
  ```
</CodeGroup>
