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

signTransaction(params: {
  walletMetadata: WalletMetadata;
  transaction: VersionedTransaction | Transaction | string;
  password?: string;
  externalServerKeyShares?: ServerKeyShare[];
  sponsor?: boolean;
}): Promise<string>

Description

Signs an SVM transaction using the wallet identified by the supplied walletMetadata. The SDK is stateless — every call requires walletMetadata. Accepts a Transaction, VersionedTransaction, or hex string. Optionally requests gas sponsorship from Dynamic before signing.
When you pass externalServerKeyShares (the caller-supplied path), walletMetadata.externalServerKeySharesBackupInfo must also be present — signTransaction 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

  • walletMetadata (WalletMetadata) - Non-sensitive wallet metadata persisted from createWalletAccount() / importPrivateKey(). The signer address comes from walletMetadata.accountAddress.
  • transaction (VersionedTransaction | Transaction | string) - The transaction to sign

Optional Parameters

  • password (string) - Required if the wallet was created with backUpToDynamic: true.
  • externalServerKeyShares (ServerKeyShare[]) - Caller-supplied plaintext shares.
  • sponsor (boolean) - If true, requests gas sponsorship from Dynamic before signing. Requires a Transaction or VersionedTransaction (not a hex string).

Returns

  • Promise<string> - The signed transaction encoded as base58

Example

import { authenticatedSvmClient } from './client';
import { Transaction, SystemProgram, LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js';

const svmClient = await authenticatedSvmClient();

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

const transaction = new Transaction().add(
  SystemProgram.transfer({
    fromPubkey: new PublicKey(walletMetadata.accountAddress),
    toPubkey: new PublicKey('11111111111111111111111111111112'),
    lamports: LAMPORTS_PER_SOL * 0.001,
  })
);

const signedTx = await svmClient.signTransaction({
  walletMetadata,
  externalServerKeyShares,
  transaction,
  password: 'user-password',
});

console.log('Signed transaction:', signedTx);