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

- Snap
- Restricted

# snap_getEntropy

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[​](#parameters "Direct link to Parameters")

object

required

An object containing the 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[​](#returns "Direct link to Returns")

\`0x${string}\`

The entropy as a hexadecimal string.

## Example

- Manifest
- Usage

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

```

```
const entropy = await snap.request({
  method: 'snap_getEntropy',
  params: {
    version: 1,
    salt: 'foo', // Optional.
  },
})

// '0x...'
console.log(entropy)

```
