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

# signAndSubmitTransaction (Aptos)

# signAndSubmitTransaction

Signs and submits an Aptos transaction to the network in a single step. This is the most common way to execute transactions on Aptos.

## Usage

```javascript theme={"system"}
import { signAndSubmitTransaction, isAptosWalletAccount } from "@dynamic-labs-sdk/aptos";
import { getPrimaryWalletAccount } from "@dynamic-labs-sdk/client";

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isAptosWalletAccount(walletAccount)) {
  const { hash } = await signAndSubmitTransaction({
    transaction: {
      function: "0x1::aptos_account::transfer",
      functionArguments: [recipientAddress, amount],
    },
    walletAccount,
  });

  console.log("Transaction submitted:", hash);
}
```

## React

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

function AptosTransferButton({ recipientAddress, amount }) {
  const { data: walletAccounts = [] } = useGetWalletAccounts();
  const walletAccount = walletAccounts.find(isAptosWalletAccount);
  const [hash, setHash] = useState('');

  const handleSubmit = async () => {
    if (!walletAccount) return;
    const { hash } = await signAndSubmitTransaction({
      walletAccount,
      transaction: {
        function: '0x1::aptos_account::transfer',
        functionArguments: [recipientAddress, amount],
      },
    });
    setHash(hash);
  };

  return (
    <div>
      <button onClick={handleSubmit} disabled={!walletAccount}>Send APT</button>
      {hash && <p>Hash: {hash}</p>}
    </div>
  );
}
```

## Parameters

| Parameter       | Type                       | Description                                                             |
| --------------- | -------------------------- | ----------------------------------------------------------------------- |
| `transaction`   | `AptosTransactionPayload`  | The transaction payload to sign and submit                              |
| `walletAccount` | `AptosWalletAccount`       | The wallet account to sign the transaction with                         |
| `client`        | `DynamicClient` (optional) | The Dynamic client instance. Only required when using multiple clients. |

## Returns

`Promise<{ hash: string }>` - A promise that resolves to an object containing the transaction hash.

## Errors

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

## Related functions

* [signTransaction](/javascript/reference/aptos/sign-transaction) - Sign a transaction without submitting
* [getAptosClient](/javascript/reference/aptos/get-aptos-client) - Get the Aptos client from a wallet account
