personal_sign
Presents a plain text signature challenge to the user and returns the signed response. Equivalent to eth_sign
on some other wallets, and prepends a safe prefix to the signed message to prevent the challenge tricking users into signing a financial transaction. This method requires that the user has granted permission to interact with their account first, so make sure to call eth_requestAccounts
(recommended) or wallet_requestPermissions
first.
Params
(2)1. Challenge (required)
A hex-encoded UTF-8 string to present to the user. See how to encode a string like this in the browser-string-hexer
module.
string
Match pattern:
^0x[a-fA-F\d]+$
2. Address (required)
The address of the requested signing account.
string
Match pattern:
^0x[0-9a-fA-F]{40}$
Result
(Signature)A hex-encoded 129-byte array starting with 0x
.
string
Match pattern:
^0x[0-9a-f]*$
Example
Request
await window.ethereum.request({
"method": "personal_sign",
"params": [
{
"challenge": "0x506c65617365207369676e2074686973206d65737361676520746f20636f6e6669726d20796f7572206964656e746974792e",
"address": "0x4B0897b0513FdBeEc7C469D9aF4fA6C0752aBea7"
}
]
});
Result
"0x43d7215ebe96c09a5adac69fc76dea5647286b501954ea273e417cf65e6c80e1db4891826375a7de02467a3e01caf125f64c851a8e9ee9467fd6f7e83523b2115bed8e79d527a85e28a36807d79b85fc551b5c15c1ead2e43456c31f565219203db2aed86cb3601b33ec3b410836d4be7718c6148dc9ac82ecc0a04c5edecd8914"