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.
Returns an object with
signature as Uint8Array and the
publicKey used to sign the message.
<Uint8Array>- Encoded message (see example for example of how to encode the message)
signature: <Uint8Array>- Message signature
publicKey: <string>- Public Key of account used to sign message
const message = 'I am the real Satoshi Nakamoto';
const encodedMessage = new TextEncoder().encode(message);
const signedMessage = await window.solana.signMessage(encodedMessage);