To sign and send transactions with Solana, you need to use the signer. You can access it via the getSigner method.

Usage

import { getSigner } from '@dynamic-labs-sdk/solana';

const sendTransaction = async (walletAccount, transaction) => {
  const signer = await getSigner({ walletAccount });
  const { signature } = await signer.signAndSendTransaction(transaction);
  console.log('Transaction sent successfully.', signature);
};

Signer methods

  • signAllTransactions: Sign multiple transactions using the specified wallet account
  • signAndSendTransaction: Sign and send a transaction using the specified wallet account
  • signMessage: Sign a message using the specified wallet account
  • signTransaction: Sign a transaction using the specified wallet account

Error Handling

  • If the specified wallet account is not a SolanaWalletAccount, it will throw an NotSolanaProviderError error.
  • If the specified wallet account is not available for signing (e.g. wallet is an external wallet and the specific account is not the active one in the wallet app, or not connected to your app), it will throw an WalletAccountNotSelectedError error, stating what is the expected account address to be used, and the active account address in the wallet app (if available).