The package that gives access to an Extension that allows integrating Viem to our client.

Functions

ViemExtension method

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.

The reference types below are simplified for the sake of readability. See the type specification for details.

PropertyTypeDescription
createPublicClient(params: { chain: Chain }) => PublicClientCreates a public viem client to interact with the given chain.
createWalletClient(params: { wallet: BaseWallet, chain?: Chain }) => WalletClientCreates a wallet viem client to interact with the given wallet address.

Types

IViemExtension type

Type of the react native extension.

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