Skip to main content
  • Snap
  • Restricted

snap_manageState

Description

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

union

The request parameters for the snap_manageState method.

Options

object

The clear state operation, which clears the state.

operation

"clear"
required

The operation to perform on the state. Must be clear.

or

object

The get state operation, which retrieves the state.

operation

"get"
required

The operation to perform on the state. Must be get.

or

object

The update state operation, which updates the state.

operation

"update"
required

The operation to perform on the state. Must be update.

newState

Record<string, Json>
required

The new state to set.

Common properties

encrypted

boolean

Whether to use the separate encrypted state, or the unencrypted state. Defaults to the encrypted state. Encrypted state can only be used if the extension is unlocked, while unencrypted state can be used whether the extension is locked or unlocked.

Returns

Record<string, Json> | null

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

Example

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