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

# Sign a Transaction

> Sign an EVM transaction without broadcasting it to the network.

Use `signTransaction` on a Viem [WalletClient](https://viem.sh/docs/clients/wallet) to produce a signed, serialized transaction **without** submitting it. This is useful when you need to:

* Hand the signed transaction to a relayer or sponsor service for submission.
* Co-sign a multi-step flow before broadcasting atomically.
* Inspect or store the raw signed bytes before sending.

## Usage

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={"system"}
    import { parseEther } from 'viem';
    import { createWalletClientForWalletAccount } from '@dynamic-labs-sdk/evm/viem';

    const signTransaction = async (walletAccount) => {
      const walletClient = await createWalletClientForWalletAccount({ walletAccount });

      const signedTx = await walletClient.signTransaction({
        to: '0x0000000000000000000000000000000000000000',
        value: parseEther('0.05'),
      });

      console.log('signed transaction:', signedTx);
      return signedTx;
    };
    ```
  </Tab>

  <Tab title="React">
    ```tsx theme={"system"}
    import { parseEther } from 'viem';
    import { createWalletClientForWalletAccount } from '@dynamic-labs-sdk/evm/viem';
    import { isEvmWalletAccount } from '@dynamic-labs-sdk/evm';
    import { useGetWalletAccounts } from '@dynamic-labs-sdk/react-hooks';

    function SignTransactionButton() {
      const { data: walletAccounts = [] } = useGetWalletAccounts();
      const walletAccount = walletAccounts.find(isEvmWalletAccount);

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

        const walletClient = await createWalletClientForWalletAccount({ walletAccount });

        const signedTx = await walletClient.signTransaction({
          to: '0x0000000000000000000000000000000000000000',
          value: parseEther('0.05'),
        });

        console.log('signed transaction:', signedTx);
      };

      return (
        <button onClick={handleSign} disabled={!walletAccount}>
          Sign transaction
        </button>
      );
    }
    ```
  </Tab>
</Tabs>

## Submitting later

The output of `signTransaction` is a serialized, signed transaction (hex). When you're ready to broadcast it, send it through any RPC — for example, with a Viem `PublicClient`:

```javascript theme={"system"}
import { createPublicClientFromNetworkData } from '@dynamic-labs-sdk/evm/viem';
import { getActiveNetworkData } from '@dynamic-labs-sdk/client';

const { networkData } = await getActiveNetworkData({ walletAccount });
const publicClient = createPublicClientFromNetworkData({ networkData });

const txHash = await publicClient.sendRawTransaction({
  serializedTransaction: signedTx,
});
```

## Notes

* The wallet account must be an EVM account. Narrow the type with [`isEvmWalletAccount`](/javascript/reference/evm/checking-evm-wallet-account-type) before calling `createWalletClientForWalletAccount`.
* Some wallet apps refuse to sign without broadcasting — they will surface a user-rejection error in that case. Check the wallet's UX expectations before relying on this flow in production.
* Signing uses the wallet's currently active chain. Switch first with [`switchActiveNetwork`](/javascript/reference/wallets/switch-active-network) if you need a different one.
* Need to estimate fees before signing? See [Calculate EVM transaction fee](/javascript/reference/evm/calculate-evm-transaction-fee).

## Related functions

* [Getting a Viem WalletClient](/javascript/reference/evm/getting-viem-wallet-client)
* [Getting a Viem PublicClient](/javascript/reference/evm/getting-viem-public-client)
* [Sign Typed Data (EIP-712)](/javascript/reference/evm/sign-typed-data)
* [Simulate EVM transaction](/javascript/reference/evm/simulate-evm-transaction)
* [Calculate EVM transaction fee](/javascript/reference/evm/calculate-evm-transaction-fee)
