---
title: Storage handlers
category: reference
---

# Storage handlers

The storage handlers expose Ledger Wallet's per-app key-value store to a Live App. Data is namespaced by application so two Live Apps cannot read or overwrite each other's keys without an explicit `storeId`.

## Method IDs

| Method ID     | Direction         | Purpose                                  |
| ------------- | ----------------- | ---------------------------------------- |
| `storage.set` | Live App → Wallet | Store a string value under a given key.  |
| `storage.get` | Live App → Wallet | Retrieve a string value for a given key. |

Both methods require the wallet to implement the matching `walletHandler` (`storage.set` / `storage.get`). If the wallet does not, the server throws an `RpcError` with code `SERVER_ERROR` (`-32000`) wrapping a `not implemented by wallet` server error.

## `storage.set`

Stores a string value under the given key. The default store is the calling app's `appId` from [`walletContext.config`](../reference#walletcontextconfig); pass `storeId` to write into a specific store.

### Parameters

| Parameter | Type     | Required | Notes                                                                                                           |
| --------- | -------- | :------: | --------------------------------------------------------------------------------------------------------------- |
| `key`     | `string` |    yes   | Key under which to store the value.                                                                             |
| `value`   | `string` |    yes   | Value to store. The store only accepts strings; serialize objects yourself (for example with `JSON.stringify`). |
| `storeId` | `string` |    no    | Store to write into. Defaults to `context.config.appId`.                                                        |

### Result

Resolves with `undefined` (the schema is `z.void().optional()`).

### Errors

| Condition                               | Error                                                                                   |
| --------------------------------------- | --------------------------------------------------------------------------------------- |
| `key` or `value` missing or wrong type  | `RpcError` with code `INVALID_PARAMS` (`-32602`).                                       |
| Wallet does not implement `storage.set` | `RpcError` with code `SERVER_ERROR` (`-32000`), data wraps `not implemented by wallet`. |

## `storage.get`

Retrieves the value previously stored under `key`. Returns `undefined` if the key does not exist.

### Parameters

| Parameter | Type                    | Required | Notes                                                   |
| --------- | ----------------------- | :------: | ------------------------------------------------------- |
| `key`     | `string` (min length 1) |    yes   | Key to read.                                            |
| `storeId` | `string` (min length 1) |    no    | Store to read from. Defaults to `context.config.appId`. |

### Result

Resolves with `{ value: string | undefined }`. The value is `undefined` when the key has never been set in the targeted store.

### Errors

| Condition                               | Error                                             |
| --------------------------------------- | ------------------------------------------------- |
| `key` missing, empty, or wrong type     | `RpcError` with code `INVALID_PARAMS` (`-32602`). |
| Wallet does not implement `storage.get` | `RpcError` with code `SERVER_ERROR` (`-32000`).   |

## See also

- [Storage module (client)](../../core/modules/storage): the client-side counterpart used by Live Apps.
- [Server reference](../reference): `walletContext.config`, permissions, and how handlers are wired in.
- [`storage.set` source](https://github.com/LedgerHQ/wallet-api/blob/main/packages/server/src/internalHandlers/storage.ts) and [`StorageSet` / `StorageGet` schemas](https://github.com/LedgerHQ/wallet-api/blob/main/packages/core/src/spec/types/StorageSet.ts).
