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

# signAndExecuteTransaction (Sui)

# signAndExecuteTransaction

Signs and executes a Sui transaction in a single step. This is the most common way to execute transactions on Sui.

## Usage

```javascript theme={"system"}
import { signAndExecuteTransaction, isSuiWalletAccount, getSuiClient } from "@dynamic-labs-sdk/sui";
import { getPrimaryWalletAccount } from "@dynamic-labs-sdk/client";
import { Transaction } from "@mysten/sui/transactions";

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isSuiWalletAccount(walletAccount)) {
  // Build a transaction
  const tx = new Transaction();
  tx.transferObjects(
    [tx.object("0x...")],
    tx.pure.address(recipientAddress)
  );

  // Sign and execute the transaction
  const result = await signAndExecuteTransaction({
    transaction: tx,
    walletAccount,
  });

  console.log("Transaction digest:", result.digest);
}
```

## Parameters

| Parameter       | Type                       | Description                                                               |
| --------------- | -------------------------- | ------------------------------------------------------------------------- |
| `transaction`   | `Transaction`              | The Sui transaction to sign and execute (from `@mysten/sui/transactions`) |
| `walletAccount` | `SuiWalletAccount`         | The wallet account to sign the transaction with                           |
| `client`        | `DynamicClient` (optional) | The Dynamic client instance. Only required when using multiple clients.   |

## Returns

`Promise<SuiSignAndExecuteTransactionResult>` - A promise that resolves to an object containing the transaction result, including:

* `digest` - The transaction digest
* `signature` - The transaction signature

## Errors

| Error                 | Description                                                   |
| --------------------- | ------------------------------------------------------------- |
| `NotSuiProviderError` | Thrown if the wallet account's provider is not a Sui provider |

## React

```tsx theme={"system"}
import { signAndExecuteTransaction, isSuiWalletAccount } from '@dynamic-labs-sdk/sui';
import { useGetWalletAccounts } from '@dynamic-labs-sdk/react-hooks';
import { useState } from 'react';
import { Transaction } from '@mysten/sui/transactions';

function SuiTransferButton({ objectId, recipientAddress }) {
  const { data: walletAccounts = [] } = useGetWalletAccounts();
  const walletAccount = walletAccounts.find(isSuiWalletAccount);
  const [digest, setDigest] = useState('');

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

    const tx = new Transaction();
    tx.transferObjects([tx.object(objectId)], tx.pure.address(recipientAddress));

    const result = await signAndExecuteTransaction({ transaction: tx, walletAccount });
    setDigest(result.digest);
  };

  return (
    <div>
      <button onClick={handleExecute} disabled={!walletAccount}>Transfer Object</button>
      {digest && <p>Digest: {digest}</p>}
    </div>
  );
}
```

## Related functions

* [signTransaction](/docs/javascript/reference/sui/sign-transaction) - Sign a transaction without executing
* [getSuiClient](/docs/javascript/reference/sui/get-sui-client) - Get the Sui client from a wallet account
