Skip to main content
  • Snap

snap_setState

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).

If the key is undefined, the value is expected to be an object. In this case, the value is set as the new root state.

If the key is not undefined, the value is set in the state at the key. If the key does not exist, it is created (and any missing intermediate keys are created as well).

Parameters

key

string | null

The key of the state to update. If not provided, the entire state is updated. This may contain Lodash-style path syntax, e.g., a.b.c, with the exception of array syntax.

value

Jsonrequired

The value to set the state to.

encrypted

boolean | null

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

Example

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