Function Signature

signTransaction(params: {
  senderAddress: string;
  transaction: Transaction;
}): Promise<VersionedTransaction | Transaction>

Description

Signs an SVM transaction using the specified wallet address. This function requires a valid session ID for authentication and returns the signed transaction object.

Parameters

Required Parameters

  • senderAddress (string) - The wallet address to sign with
  • transaction (Transaction) - The transaction to sign (Solana web3.js format)

Returns

  • Promise<VersionedTransaction | Transaction> - The signed transaction object

Example

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

const svmClient = await authenticatedSvmClient();

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

const signedTx = await svmClient.signTransaction({
  senderAddress: 'YourSolanaWalletAddress',
  transaction: transaction,
});

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

Error Handling

try {
  const signedTx = await svmClient.signTransaction({
    senderAddress: 'YourSolanaWalletAddress',
    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
  • Session Management: Implement proper session management
  • Network Verification: Ensure you’re signing transactions for the correct Solana network