Skip to main content
MetaMask
Restricted
Deprecated

eth_decrypt

Summary: Decrypts an encrypted message.

This method is deprecated and may be removed in the future. Requests that MetaMask decrypt the specified encrypted message. The message must have been encrypted using the public encryption key of the specified Ethereum address. Returns a promise that resolves to the decrypted message, or rejects if the decryption attempt fails.

Parameters

EncryptedMessage string
required

The encrypted message to decrypt.


Address string

hex encoded address

Pattern: ^0x[0-9a-fA-F]{40}$

Returns

PermissionsList array

PermissionsList

Permission object

Permission

id string

The permission ID.

@context array

When two people communicate with one another, the conversation takes place in a shared environment, typically called 'the context of the conversation.' This shared context allows the individuals to use shortcut terms, such as the first name of a mutual friend, to communicate more quickly without losing accuracy. A context in JSON-LD works the same way: it allows two applications to use shortcut terms to communicate more efficiently without losing accuracy.

string

invoker string

A URI of the dapp being granted this permission.

caveats array

A capability document modifies the caveat property to specify usage restrictions. Capabilities inherit restrictions from the caveat properties of their parent documents and can add new caveats in addition to those inherited from their parents.

Caveat object

Caveat

type string

Type of caveat.

value

Value of the caveat.

name string

Name of the caveat.

Errors

Code
Message
4100
The requested account and/or method has not been authorized by the user.
Customize request
Parameter
Value
string
string
Connect your MetaMask wallet to run requests successfully.
Request
await window.ethereum.request({
"method": "eth_decrypt",
"params": [
"0x7b2276657273696f6e223a227832353531392d7873616c736132302d706f6c7931333035222c226e6f6e6365223a2243533967507076467071765358704655416679726a7179774e35302b7a747766222c22657068656d5075626c69634b6579223a224372774b61456d2f4b356d6d714239764c376f5872636d6441417757764479324f784c3333527135576e553d222c2263697068657274657874223a2248347a65336e7177572b753174663956343945506167454e343872774f766b6952676244566e47587a38493d227d",
"0xD1F5279BE4B4dD94133A23deE1B23F5bfC0Db1d0"
],
});
Example response
"Hello, Ethereum!"