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

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

Record<string, JSON> | null

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

Example

{
"initialPermissions": {
"snap_manageState": {}
}
}
On this page