Overview

This guide shows you how to sign messages with your Solana wallet. Message signing is commonly used for authentication, nonce verification, and data integrity checks on Solana.

Prerequisites

Basic Message Signing

import { authenticatedSvmClient } from './client';

const svmClient = await authenticatedSvmClient();

const signature = await svmClient.signMessage({
  message: 'Hello, World!',
  accountAddress: 'YourSolanaWalletAddress',
  externalServerKeyShares: [
    {
      chainName: 'solana',
      keyShare: '0xYourKeyShare',
    },
  ],
  password: 'your-password', // optional
});

console.log('Message signed:', signature);

Common Use Cases

Authentication

const nonce = Date.now().toString();
const message = `Sign this message to authenticate: ${nonce}`;
const signature = await svmClient.signMessage({
  message,
  accountAddress: 'YourSolanaWalletAddress',
  externalServerKeyShares,
});

Data Integrity

const data = { userId: 123, action: 'transfer', amount: '100' };
const message = JSON.stringify(data);
const signature = await svmClient.signMessage({
  message,
  accountAddress: 'YourSolanaWalletAddress',
  externalServerKeyShares
});

Next Steps