Skip to main content
  • Snap
  • Restricted

snap_getEntropy

Description

Get a deterministic 256-bit entropy value, specific to the Snap and the user's account. You can use this entropy to generate a private key, or any other value that requires a high level of randomness. Other Snaps can't access this entropy, and it changes if the user's secret recovery phrase changes.

You can optionally specify a salt to generate different entropy for different purposes. Using a salt results in entropy unrelated to the entropy generated without a salt.

This value is deterministic: it's always the same for the same Snap, user account, and salt.

Parameters

object

The request parameters for the snap_getEntropy method.

version

1
required

The version of the entropy to retrieve. This is reserved for future use, and as of now, only version 1 is supported.

salt

string | null

An arbitrary string to be used as a salt for the entropy. This can be used to generate different entropy for different purposes.

source

string | null

The ID of the entropy source to use. If not specified, the primary entropy source will be used. For a list of available entropy sources, see the snap_listEntropySources method.

Returns

`0x${string}`

The entropy as a hexadecimal string.

Example

{
"initialPermissions": {
"snap_getEntropy": {}
}
}