Skip to main content
Signs an Aptos transaction without submitting it to the network. This is useful when you need to collect signatures before submitting, or when working with multi-signature transactions.

Usage

import { signTransaction, isAptosWalletAccount, getAptosClient } from '@dynamic-labs-sdk/aptos';
import { getPrimaryWalletAccount } from '@dynamic-labs-sdk/client';

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isAptosWalletAccount(walletAccount)) {
  const aptosClient = await getAptosClient({ walletAccount });

  // Build a transaction
  const transaction = await aptosClient.transaction.build.simple({
    sender: walletAccount.address,
    data: {
      function: '0x1::aptos_account::transfer',
      functionArguments: [recipientAddress, amount],
    },
  });

  // Sign the transaction
  const { signature } = await signTransaction({
    transaction,
    walletAccount,
  });
}

Parameters

ParameterTypeDescription
transactionAnyRawTransactionThe transaction to sign
walletAccountAptosWalletAccountThe wallet account to sign the transaction with
asFeePayerboolean (optional)Whether to sign as the fee payer
clientDynamicClient (optional)The Dynamic client instance. Only required when using multiple clients.

Returns

Promise<{ signature: AptosSignTransactionOutput }> - A promise that resolves to an object containing the signature output.

Errors

ErrorDescription
NotAptosProviderErrorThrown if the wallet account’s provider is not an Aptos provider