Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt

Use this file to discover all available pages before exploring further.

Function Signature

signMessage(params: {
  message: string | Uint8Array;
  walletMetadata: WalletMetadata;
  password?: string;
  externalServerKeyShares?: ServerKeyShare[];
}): Promise<string>

Description

Signs a message using the SVM wallet identified by the supplied walletMetadata. The SDK is stateless — every call requires walletMetadata. If the wallet was created with backUpToDynamic: true, supply the password so the SDK can recover shares from backup when externalServerKeyShares is omitted.
When you pass externalServerKeyShares (the caller-supplied path), walletMetadata.externalServerKeySharesBackupInfo must also be present — signMessage throws if shares are supplied but backup metadata is missing. The full walletMetadata returned from createWalletAccount / importPrivateKey already includes it; identity-only metadata from fetchWalletMetadata will be rejected.

Parameters

Required Parameters

  • message (string | Uint8Array) - The message to sign
  • walletMetadata (WalletMetadata) - Non-sensitive wallet metadata persisted from createWalletAccount() / importPrivateKey().

Optional Parameters

  • password (string) - Required if the wallet was created with backUpToDynamic: true.
  • externalServerKeyShares (ServerKeyShare[]) - Caller-supplied plaintext shares. If omitted, the SDK recovers from backup using password.

Returns

  • Promise<string> - The serialized signature (base58)

Example

import { authenticatedSvmClient } from './client';

const svmClient = await authenticatedSvmClient();

const walletMetadata = JSON.parse(await redis.get(`wallet:${accountAddress}`));
const externalServerKeyShares = await vault.read(`wallet:${accountAddress}/shares`);

const signature = await svmClient.signMessage({
  message: 'Hello, World!',
  walletMetadata,
  externalServerKeyShares,
  password: 'user-password',
});

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