> ## Documentation Index
> Fetch the complete documentation index at: https://www.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# signTransaction (Aptos)

# signTransaction

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

```javascript theme={"system"}
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

| Parameter       | Type                       | Description                                                             |
| --------------- | -------------------------- | ----------------------------------------------------------------------- |
| `transaction`   | `AnyRawTransaction`        | The transaction to sign                                                 |
| `walletAccount` | `AptosWalletAccount`       | The wallet account to sign the transaction with                         |
| `asFeePayer`    | `boolean` (optional)       | Whether to sign as the fee payer                                        |
| `client`        | `DynamicClient` (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

| Error                   | Description                                                      |
| ----------------------- | ---------------------------------------------------------------- |
| `NotAptosProviderError` | Thrown if the wallet account's provider is not an Aptos provider |

## React

```tsx theme={"system"}
import { signTransaction, isAptosWalletAccount, getAptosClient } from '@dynamic-labs-sdk/aptos';
import { useGetWalletAccounts } from '@dynamic-labs-sdk/react-hooks';
import { useState } from 'react';

function SignTransactionButton({ recipientAddress, amount }) {
  const { data: walletAccounts = [] } = useGetWalletAccounts();
  const walletAccount = walletAccounts.find(isAptosWalletAccount);
  const [signed, setSigned] = useState(false);

  const handleSign = async () => {
    if (!walletAccount) return;

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

    await signTransaction({ transaction, walletAccount });
    setSigned(true);
  };

  return (
    <div>
      <button onClick={handleSign} disabled={!walletAccount}>Sign Transaction</button>
      {signed && <p>Transaction signed</p>}
    </div>
  );
}
```

## Related functions

* [signAndSubmitTransaction](/docs/javascript/reference/aptos/sign-and-submit-transaction) - Sign and submit a transaction in one step
* [getAptosClient](/docs/javascript/reference/aptos/get-aptos-client) - Get the Aptos client from a wallet account
