Function Signature

signTransaction(params: {
  senderAddress: string;
  externalServerKeyShares: any[];
  transaction: TransactionSerializable;
  password?: string;
}): Promise<string>

Description

Signs an EVM transaction using the specified wallet address. This function requires external server key shares and a valid session ID for authentication.

Parameters

Required Parameters

  • senderAddress (string) - The wallet address to sign with (must include 0x prefix)
  • externalServerKeyShares (any[]) - Array of external server key shares
  • transaction (TransactionSerializable) - The transaction to sign (viem format)

Optional Parameters

  • password (string) - Wallet password (if wallet is password-protected)

Returns

  • Promise<string> - The signed transaction as a hex string

Example

import { authenticatedEvmClient } from './client';
import { parseEther } from 'viem/utils';

const evmClient = await authenticatedEvmClient();

const signedTx = await evmClient.signTransaction({
  senderAddress: '0xYourWalletAddress',
  externalServerKeyShares: [
    {
      chainName: 'base-sepolia',
      keyShare: '0x1234567890',
    },
  ],
  transaction: {
    to: '0xRecipientAddress',
    value: parseEther('0.1'),
    chain: base,
    account: '0xYourWalletAddress',
  },
  password: 'optional-password',
});

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

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 signedTx = await evmClient.signTransaction({
    senderAddress: '0xYourWalletAddress',
    externalServerKeyShares: keyShares,
    transaction: tx,
  });
  console.log('Transaction signed successfully');
} catch (error) {
  console.error('Failed to sign transaction:', error);
}

Security Considerations

  • Transaction Validation: Always validate transaction parameters before signing
  • Key Share Security: Keep external server key shares secure
  • Session Management: Implement proper session management
  • Network Verification: Ensure you’re signing transactions for the correct network