Signing Messages
Your app is able to request approval to sign messages after it has established a connection to the wallet provider. A popup window displaying the message is opened when you request approval from a user. The user can either approve or reject the request.
Message signatures do not incur network fees, and they are often used by apps to verify ownership of an address.
Provider Method
signMessage
Returns an object with signature
as Uint8Array and the publicKey
used to sign the message.
Parameters:
<Uint8Array>
- Encoded message (see example for example of how to encode the message)
Results:
<object>
signature: <Uint8Array>
- Message signaturepublicKey: <string>
- Public Key of account used to sign message
Example
Sign Message
const message = 'I am the real Satoshi Nakamoto';
const encodedMessage = new TextEncoder().encode(message);
const signedMessage = await window.solana.signMessage(encodedMessage);