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

# viem-extension

The package that gives access to an [Extension](/react-native/reference/package-references/client#extension-method)
that allows integrating Viem to our [client](/react-native/reference/client).

## Functions

### `ViemExtension` method

```typescript theme={"system"}
ViemExtension(): Extension<IViemExtension>
```

A method that, when passed to the client instance, injects the following modules into it:

#### `viem` module

Provides methods to create viem clients.

<Info>
  The reference types below are simplified for the sake of readability. See the
  [type specification](#iviemextension-type) for details.
</Info>

| Property             | Type                                                              | Description                                                             |
| -------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `createPublicClient` | `(params: { chain: Chain }) => PublicClient`                      | Creates a public viem client to interact with the given chain.          |
| `createWalletClient` | `(params: { wallet: BaseWallet, chain?: Chain }) => WalletClient` | Creates a wallet viem client to interact with the given wallet address. |

## Types

### `IViemExtension` type

Type of the react native extension.

```typescript theme={"system"}
import {
  Account,
  Chain,
  CustomTransport,
  PublicClient,
  PublicClientConfig,
  WalletClient,
  WalletClientConfig,
} from 'viem'

type PublicClientConfigDynamic<C extends Chain | undefined> = Omit<
  PublicClientConfig<CustomTransport, C>,
  'transport'
> & { chain: NonNullable<PublicClientConfig<CustomTransport, C>['chain']> }

type WalletClientConfigDynamic<C extends Chain | undefined> = Omit<
  WalletClientConfig<CustomTransport, C>,
  'transport' | 'account'
> & { wallet: BaseWallet }

type IViemExtension = {
  viem: {
    createPublicClient: <C extends Chain | undefined = undefined>(
      params: PublicClientConfigDynamic<C>
    ) => PublicClient<CustomTransport, C>

    createWalletClient: <C extends Chain | undefined = undefined>(
      params: WalletClientConfigDynamic<C>
    ) => WalletClient<CustomTransport, C, Account>
  }
}
```
