The Otim Client provides a unified interface for interacting with the Otim Protocol. The createOtimClient function accepts different configuration options depending on your application type and wallet management needs.

Initialization Methods

The Otim Client can be initialized in three different ways:
  1. Wallet Client – For frontend applications using wagmi or existing viem wallet clients
  2. Transport + Chain + Account – For backend services and direct configuration
The Otim Client can accept an existing viem wallet client instance, allowing you to reuse wallet configurations across different parts of your application.
Note: The next example is using wagmi, but the wallet client can be from viem too.
import { createOtimClient } from '@otim/sdk';
import { useWalletClient } from 'wagmi';

const result = useWalletClient();

const otimClient = createOtimClient({
  walletClient: result.data, // pre-configured wallet client
  authorizationToken?: string // optional: pre-existing auth token
});

When to use

  • You have an existing viem WalletClient instance
  • Advanced applications with custom wallet management
  • Integration with existing viem-based infrastructure
  • You need to share wallet clients between different parts of your application

Benefits

  • Reuse existing wallet client configuration
  • No additional wallet client creation overhead
  • Full compatibility with viem ecosystem
  • Maximum flexibility for complex setups

2. Using Transport + Chain + Account (Backend – Direct Configuration)

The Otim Client accepts direct wallet configuration through transport, chain, and account parameters. This method creates a new wallet client internally and provides full control over the configuration.
import { createOtimClient } from '@otim/sdk';
import { http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { sepolia } from 'viem/chains';

// backend example with private key

const account = privateKeyToAccount("0x...");

const otimClient = createOtimClient({
  transport: http(),
  chain: sepolia,
  account: account,
  authorizationToken?: string // optional: pre-existing auth token
});

When to use

  • Backend services and server-side applications
  • You have direct access to private keys
  • You need explicit control over transport and chain configuration
  • Building automated systems or bots
Note: When you pass transportchain, and account, the SDK will create a new WalletClient internally using viem’s createWalletClient function. This approach is recommended for backend applications where you have direct control over the wallet configuration.