Skip to main content
Sign messages to prove ownership of a Solana address without submitting a transaction. This is commonly used for authentication and verification purposes.
import { useParaSolana } from './hooks/useParaSolana';
import bs58 from 'bs58';

function SignMessage() {
  const { signer } = useParaSolana();

  const signMessage = async () => {
    if (!signer) {
      console.error("No signer available. Connect wallet first.");
      return;
    }

    const message = "Hello, Solana!";
    const messageBytes = new TextEncoder().encode(message);

    const signature = await signer.signBytes(Buffer.from(messageBytes));
    const signatureBase58 = bs58.encode(signature);

    console.log("Message:", message);
    console.log("Signature:", signatureBase58);
    console.log("Signer:", signer.address);
  };

  return <button onClick={signMessage}>Sign Message</button>;
}

Next Steps