> For the complete documentation index, see [llms.txt](/llms.txt).

- Snap
- Restricted

# snap_manageState

Allow the Snap to persist up to 64 MB of data to disk and retrieve it at will. By default, the data is automatically encrypted using a Snap-specific key and automatically decrypted when retrieved. You can set `encrypted` to `false` to use unencrypted storage (available when the client is locked).

## Parameters[​](#parameters "Direct link to Parameters")

union

An object containing the parameters for the `snap_manageState` method.

### Options

object

required

The `clear` operation, which deletes all stored state.

### operation

"clear"

required

The literal string "clear" to indicate that this is a clear operation.

or

object

required

The `get` operation, which retrieves the stored state.

### operation

"get"

required

The literal string "get" to indicate that this is a get operation.

or

object

required

The `update` operation, which replaces the stored state with a new value.

### operation

"update"

required

The literal string "update" to indicate that this is an update operation.

### newState

Record<string, JSON>

required

The new state to store. Must be a JSON-serializable object.

### Common properties

### encrypted

boolean

Whether to use the encrypted or unencrypted state. Defaults to `true`(encrypted). Encrypted state is only accessible when the wallet is unlocked, while unencrypted state is accessible whether the wallet is locked or unlocked. State can be cleared regardless of the wallet's lock state, but this parameter determines which state is cleared.

## Returns[​](#returns "Direct link to Returns")

Record<string, JSON> | null

If the operation is `get`, the result is the state. Otherwise, the result is `null`.

## Example

- Manifest
- Usage

```
{
  "initialPermissions": {
    "snap_manageState": {}
  }
}

```

```
// Persist some data.
await snap.request({
  method: 'snap_manageState',
  params: {
    operation: 'update',
    newState: { hello: 'world' },
  },
})

// At a later time, get the stored data.
const persistedData = await snap.request({
  method: 'snap_manageState',
  params: { operation: 'get' },
})

console.log(persistedData)
// { hello: 'world' }

// If there's no need to store data anymore, clear it out.
await snap.request({
  method: 'snap_manageState',
  params: {
    operation: 'clear',
  },
})

```
