Skip to main content
There are three functions to sign and send transactions with Solana:
  • signAndSendTransaction: Sign and send a single transaction
  • signTransaction: Sign a transaction
  • signAllTransactions: Sign multiple transactions

Usage

import { signAndSendTransaction, signTransaction, signAllTransactions } from '@dynamic-labs-sdk/solana';

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

const signTransaction = async (walletAccount, transaction) => {
  const { signedTransaction } = await signTransaction({ transaction, walletAccount });
  console.log('Transaction signed successfully.', signedTransaction);
};

const signTransactions = async (walletAccount, transactions) => {
  const { signedTransactions } = await signAllTransactions({ transactions, walletAccount });
  console.log('Transactions signed successfully.', signedTransactions);
};

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).