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

<Tabs>
  <Tab title="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>

  <Tab title="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 { useGetWalletAccounts } from '@dynamic-labs-sdk/react-hooks';

    function SendTransactionButton({ transaction }) {
      const { data: walletAccounts = [] } = useGetWalletAccounts();
      const walletAccount = walletAccounts[0];

      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>
      );
    }
    ```
  </Tab>
</Tabs>

## 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](/react/reference/using-wagmi).
</Note>

## Related functions

* [Adding EVM extensions](/javascript/reference/evm/adding-evm-extensions)
* [Getting Viem Public Client](/javascript/reference/evm/getting-viem-public-client)
