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

# Getting a Viem WalletClient

[Viem](https://viem.sh/) is one of the most popular libraries for interacting with EVM blockchains.

A [WalletClient](https://viem.sh/docs/clients/wallet) is an interface to interact with EVM accounts and provides the ability to retrieve accounts, execute transactions, sign messages, etc.

We provide a helper method to allow you to create a Viem WalletClient for a given wallet account.

## Usage

> [tab] JavaScript
>
> ```javascript theme={"system"}
> import { createWalletClientForWalletAccount } from '@dynamic-labs-sdk/evm/viem';
>
> const sendTransaction = async (walletAccount, transaction) => {
>   const walletClient = await createWalletClientForWalletAccount({
>     walletAccount,
>   });
>
>   const result = await walletClient.sendTransaction(transaction);
>   console.log('Transaction sent:', result);
>
>   // ...
> };
> ```

> [tab] React
>
> Use `useGetWalletAccounts` to reactively get the wallet, then call `createWalletClientForWalletAccount` inside an event handler:
>
> ```tsx theme={"system"}
> import { createWalletClientForWalletAccount } from '@dynamic-labs-sdk/evm/viem';
> import { isEvmWalletAccount } from '@dynamic-labs-sdk/evm';
> import { useGetWalletAccounts } from '@dynamic-labs-sdk/react-hooks';
>
> function SendTransactionButton({ transaction }) {
>   const { data: walletAccounts = [] } = useGetWalletAccounts();
>   const walletAccount = walletAccounts.find(isEvmWalletAccount);
>
>   const handleSend = async () => {
>     if (!walletAccount) return;
>
>     const walletClient = await createWalletClientForWalletAccount({ walletAccount });
>     const result = await walletClient.sendTransaction(transaction);
>     console.log('Transaction sent:', result);
>   };
>
>   return (
>     <button onClick={handleSend} disabled={!walletAccount}>
>       Send Transaction
>     </button>
>   );
> }
> ```

## Viem / wagmi version compatibility

The JavaScript SDK's EVM extension (`@dynamic-labs-sdk/evm`) uses viem internally. If you also use wagmi in your project, ensure your versions are compatible:

| Dependency | Required range | Notes |
| :- | :- | :- |
| `viem` | `^2.45.3` | viem v2.45.3+ |
| `wagmi` | `^2.14.11` | If using wagmi alongside the SDK |
| `@wagmi/core` | `^2.6.4` | Installed automatically with wagmi |

> [!NOTE]
>
> wagmi v3.x may work (v3.1.0 has been tested), but is outside the declared peer dependency range. Full v3 support is planned for a future release. For the React SDK wagmi connector setup, see [Using Wagmi](https://docs.dynamic.xyz/docs/react/reference/using-wagmi.md).

## Related functions

* [Adding EVM extensions](https://docs.dynamic.xyz/docs/javascript/reference/evm/adding-evm-extensions.md)
* [Getting Viem Public Client](https://docs.dynamic.xyz/docs/javascript/reference/evm/getting-viem-public-client.md)


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