# View-Only Wallets

[RAILGUN Wallets](/developer-guide/wallet/private-wallets/railgun-wallets.md) (created with mnemonic) have both spending and viewing keys. View-Only wallets lack the spending key, so they cannot create transactions, but they have access to the wallet viewing key that can access balances and transaction history.&#x20;

View-Only wallets are created using a shareable viewing key. Only the original wallet owner, who has access to the RAILGUN Wallet (and mnemonic) can generate a shareable key.

#### Example: Generate shareable key and associated View-Only wallet

```typescript
import { 
    getWalletShareableViewingKey, 
    createViewOnlyRailgunWallet, 
} from '@railgun-community/wallet';

const encryptionKey = ...; // See `Encryption Keys` section

const railgunWalletID = ...; // Stored after RAILGUN wallet creation

const shareableViewingKey = await getWalletShareableViewingKey(railgunWalletID);

// Current block numbers for each chain when wallet was first created.
// If unknown, provide undefined.
const creationBlockNumberMap: Optional<MapType<number>> = undefined;

const viewOnlyWalletInfo = await createViewOnlyRailgunWallet(
  encryptionKey, 
  shareableViewingKey,
  creationBlockNumberMap,
);
const id = viewOnlyWalletInfo.id;
```

View-Only wallets may be loaded like RAILGUN Wallets, using `loadWalletByID`.

#### Example: Load stored RAILGUN Wallet by its ID

```typescript
import { loadWalletByID } from '@railgun-community/wallet';

const encryptionKey = ...; // See `Encryption Keys` section
const id = ...; // Previously stored when local RAILGUN wallet was created
const viewOnlyWalletInfo = await loadWalletByID(
  encryptionKey, 
  id, 
  true, // isViewOnlyWallet
);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.railgun.org/developer-guide/wallet/private-wallets/view-only-wallets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
