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

# 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

> [tab] 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] 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>
>   );
> }
> ```

## 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`](https://docs.dynamic.xyz/docs/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`](https://docs.dynamic.xyz/docs/javascript/reference/wallets/switch-active-network) if you need a different one.
* Need to estimate fees before signing? See [Calculate EVM transaction fee](https://docs.dynamic.xyz/docs/javascript/reference/evm/calculate-evm-transaction-fee.md).

## Related functions

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.