Skip to main content
The @0xsequence/oms-wallet-wagmi-connector package adapts an active TypeScript OMS Wallet SDK client to wagmi’s connector API. Use it when your React app already uses wagmi hooks for account state, signing, chain switching, or transaction submission. The connector does not render authentication UI. Authenticate with @0xsequence/typescript-sdk first, then connect through wagmi after the OMS Wallet session has an active wallet address.

Install

Install the TypeScript SDK, the wagmi connector package, wagmi, viem, and TanStack Query for wagmi React hooks.
pnpm add @0xsequence/typescript-sdk @0xsequence/oms-wallet-wagmi-connector wagmi viem @tanstack/react-query
For npm or yarn projects:
npm install @0xsequence/typescript-sdk @0xsequence/oms-wallet-wagmi-connector wagmi viem @tanstack/react-query
yarn add @0xsequence/typescript-sdk @0xsequence/oms-wallet-wagmi-connector wagmi viem @tanstack/react-query

Create The Wagmi Config

Create one OMSClient, pass it to omsWalletConnector, and configure wagmi chains with viem transports. Wagmi chain definitions are separate from OMS Wallet Network entries, so pass both the wagmi chains and the OMS networks.
import {
  FeeOptionSelector,
  OMSClient,
  supportedNetworks,
} from '@0xsequence/typescript-sdk'
import { omsWalletConnector } from '@0xsequence/oms-wallet-wagmi-connector'
import { createConfig, http } from 'wagmi'
import { polygon, polygonAmoy } from 'wagmi/chains'

export const oms = new OMSClient({
  publishableKey: 'YOUR_PROJECT_ACCESS_KEY',
  projectId: 'YOUR_PROJECT_ID',
})

export const wagmiConfig = createConfig({
  chains: [polygonAmoy, polygon],
  connectors: [
    omsWalletConnector({
      client: oms,
      networks: supportedNetworks,
      initialChainId: polygonAmoy.id,
      transactionOptions: {
        selectFeeOption: FeeOptionSelector.firstAvailable,
      },
    }),
  ],
  transports: {
    [polygonAmoy.id]: http(),
    [polygon.id]: http(),
  },
})

declare module 'wagmi' {
  interface Register {
    config: typeof wagmiConfig
  }
}
Parameters
ParameterTypeDescription
clientOmsWalletClientLike or functionOMSClient instance, or a function that resolves one.
networksNetwork[] or undefinedOMS Wallet networks used to validate connector chains. Defaults to client.supportedNetworks when available.
initialChainIdnumber or undefinedInitial wagmi chain ID. Must exist in wagmi chains and the OMS networks list.
transactionOptionsOmsWalletTransactionOptions or functionStatic transaction options, or a resolver called for each wagmi transaction request.
idstring or undefinedOptional connector ID. Defaults to omsWallet.
namestring or undefinedOptional connector display name. Defaults to OMS Wallet.
iconstring or undefinedOptional connector icon URL or data URI.
Returns Returns a wagmi connector from omsWalletConnector.

Wrap The React App

Pass the same wagmiConfig to WagmiProvider. Wagmi React hooks also require a TanStack Query client.
import React from 'react'
import { createRoot } from 'react-dom/client'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { WagmiProvider } from 'wagmi'
import { wagmiConfig } from './wagmiConfig'
import { App } from './App'

const queryClient = new QueryClient()

createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <WagmiProvider config={wagmiConfig}>
      <QueryClientProvider client={queryClient}>
        <App />
      </QueryClientProvider>
    </WagmiProvider>
  </React.StrictMode>,
)

Connect After OMS Auth

Authenticate with the OMS Wallet SDK before calling wagmi connect. The connector checks oms.wallet.walletAddress and rejects the connection if there is no active wallet session.
import { connect } from '@wagmi/core'
import { polygonAmoy } from 'wagmi/chains'
import { wagmiConfig, oms } from './wagmiConfig'

await oms.wallet.startEmailAuth({ email: 'user@example.com' })
await oms.wallet.completeEmailAuth({ code: '123456' })

if (!oms.wallet.walletAddress) {
  throw new Error('OMS auth completed without an active wallet.')
}

const omsConnector = wagmiConfig.connectors.find(
  (connector) => connector.type === 'omsWallet',
)

if (!omsConnector) {
  throw new Error('OMS Wallet connector is not configured.')
}

await connect(wagmiConfig, {
  connector: omsConnector,
  chainId: polygonAmoy.id,
})
For redirect-based OIDC flows, complete the SDK redirect callback first, then connect through wagmi after the wallet session is active.

Disconnect And Sign Out

Wagmi disconnect only disconnects wagmi state. It does not sign out the OMS Wallet SDK session.
import { disconnect } from '@wagmi/core'
import { wagmiConfig, oms } from './wagmiConfig'

await disconnect(wagmiConfig)
await oms.wallet.signOut()
After a wagmi-only disconnect, the connector marks itself manually disconnected and will not automatically reconnect on page refresh until the app calls wagmi connect again.

Configure Fee Options

Wagmi transaction parameters do not include OMS fee-option preferences. Use transactionOptions on the connector to apply fee selection to wagmi transactions.
import {
  FeeOptionSelector,
  supportedNetworks,
  TransactionMode,
} from '@0xsequence/typescript-sdk'
import { omsWalletConnector } from '@0xsequence/oms-wallet-wagmi-connector'
import { oms } from './wagmiConfig'

omsWalletConnector({
  client: oms,
  networks: supportedNetworks,
  transactionOptions: {
    mode: TransactionMode.Relayer,
    selectFeeOption: FeeOptionSelector.firstAvailable,
  },
})
Use a resolver when the options should depend on the wagmi transaction request.
omsWalletConnector({
  client: oms,
  networks: supportedNetworks,
  transactionOptions: ({ chainId, request }) => ({
    selectFeeOption: async (feeOptions) => {
      const usdc = feeOptions.find(
        (option) => option.feeOption.token.symbol === 'USDC',
      )

      return usdc?.selection
    },
  }),
})
The connector calls selectFeeOption after preparing the transaction. The selector receives FeeOptionWithBalance[], including each fee option and wallet balance data when available. Use FeeOptionSelector.firstAvailable to choose the first option the wallet can pay, or return option.selection from a custom selector.

Send Transactions With Wagmi

Use wagmi transaction APIs after connecting. The connector always waits for an EVM transaction hash because wagmi sendTransaction must return a hash.
import { sendTransaction } from '@wagmi/core'
import { parseEther, type Address } from 'viem'
import { polygonAmoy } from 'wagmi/chains'
import { wagmiConfig } from './wagmiConfig'

const hash = await sendTransaction(wagmiConfig, {
  chainId: polygonAmoy.id,
  to: '0xRecipient' as Address,
  value: parseEther('0.01'),
})
Supported transaction fields are from, to, value, data, and chainId. The to field is required, so contract deployment is not supported through this connector. The connector ignores wallet-managed execution fields that OMS Wallet does not accept through this path: gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, type, and accessList. Unknown transaction fields are rejected. waitForStatus: false is not supported through the connector. Use oms.wallet.sendTransaction directly when you need the OMS transaction ID before an EVM transaction hash is available.

Provider Scope

Use the connector through wagmi APIs. Do not treat getProvider() as a general RPC provider. Supported provider methods are limited to wallet operations that map to the SDK:
MethodUse
eth_accountsRead the active OMS Wallet account.
eth_requestAccountsConnect the active OMS Wallet session.
wallet_switchEthereumChainSwitch across configured wagmi chains that OMS Wallet supports.
personal_signSign string messages.
eth_signTypedData_v4Sign typed data.
eth_sendTransactionSend a transaction through OMS Wallet.
wallet_sendTransactionSend a transaction through OMS Wallet.
wallet_getCapabilitiesReturns no capabilities unless OMS Wallet adds capability support.
Direct read/RPC methods such as eth_call, eth_estimateGas, eth_getBalance, eth_getCode, eth_getTransactionCount, eth_getTransactionReceipt, and eth_blockNumber are not supported by the OMS Wallet provider. Use wagmi public transports for reads, or call oms.wallet directly for SDK operations. Raw byte message signing is not supported because OMS Wallet signs string messages. Use personal_sign for messages and eth_signTypedData_v4 for typed data.