Function Signature

signMessage(params: {
  message: string;
  accountAddress: string;
  externalServerKeyShares?: any[];
  password?: string;
}): Promise<string>

Description

Signs a message using the specified EVM wallet address. This function optionally accepts external server key shares for advanced key management scenarios.

Parameters

Required Parameters

  • message (string) - The message to sign
  • accountAddress (string) - The wallet address to sign with (must include 0x prefix)

Optional Parameters

  • externalServerKeyShares (any[]) - Array of external server key shares (for advanced key management)
  • password (string) - Wallet password (if wallet is password-protected)

Returns

  • Promise<string> - The serialized signature

Example

import { authenticatedEvmClient } from './client';

const evmClient = await authenticatedEvmClient();

const signature = await evmClient.signMessage({
  message: 'Hello, World!',
  accountAddress: '0xYourWalletAddress',
  externalServerKeyShares: [
    {
      chainName: 'base-sepolia',
      keyShare: '0x1234567890',
    },
  ],
  password: 'optional-password',
});

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

Key Share Format

interface KeyShare {
  chainName: string;
  keyShare: string;
}

const externalServerKeyShares: KeyShare[] = [
  {
    chainName: 'base-sepolia', // or your specific chain
    keyShare: '0x1234567890', // the actual key share
  },
];

Error Handling

try {
  const signature = await evmClient.signMessage({
    message: 'Hello world',
    accountAddress: '0xYourWalletAddress',
    externalServerKeyShares,
  });
  console.log('Message signed successfully');
} catch (error) {
  console.error('Failed to sign message:', error);
}

Security Considerations

  • Message Validation: Always validate message content before signing
  • Key Share Security: Keep external server key shares secure
  • Session Management: Implement proper session management
  • Password Protection: Use strong passwords for wallet encryption