signMessage
Calculates an Ethereum-specific signature in the form of keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))
.
Takes a byte array or hex value as the data
argument.
Usage
ts
import { walletClient } from '.'
const message = await walletClient.signMessage({
account: getAccount('0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'),
data: '0xdeadbeaf',
})
// "0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b"
Returns
The signed message.
Parameters
account
- Type:
Address
Account to use for signing. Read more.
ts
const message = await walletClient.signMessage({
account: getAccount('0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'),
data: '0xdeadbeaf',
})
data
- Type:
string
Message to sign.
ts
const message = await walletClient.signMessage({
account: getAccount('0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'),
data: 'hello world',
})
JSON-RPC Methods
- JSON-RPC Accounts:
- Local Accounts
- Signs locally. No JSON-RPC request.