# Ethereum wallet configuration

Configure Ethereum (EVM) embedded wallets through the `ethereum` key of `walletConfig`. For shared options and the Solana setup, see [Wallet configuration](/docs/products/embedded-wallet/react/wallet).

```tsx [Providers.tsx]
import { OpenfortProvider } from "@openfort/react"
import { getDefaultConfig, OpenfortWagmiBridge } from "@openfort/react/wagmi"
import { WagmiProvider, createConfig } from "wagmi"
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
import { baseSepolia } from "viem/chains"

const config = createConfig(
  getDefaultConfig({
    appName: "My App",
    chains: [baseSepolia],
    ssr: true, // set to true for Next.js
  })
)

const queryClient = new QueryClient()

export function Providers({ children }: { children: React.ReactNode }) {
  return (
    <QueryClientProvider client={queryClient}>
      <WagmiProvider config={config}>
        <OpenfortWagmiBridge>
          <OpenfortProvider
            publishableKey="YOUR_OPENFORT_PUBLISHABLE_KEY"
            walletConfig={{  // [!code focus]
              shieldPublishableKey: "YOUR_SHIELD_PUBLISHABLE_KEY",  // [!code focus]
              ethereum: { chainId: 84532 },  // [!code focus]
              connectOnLogin: true,  // [!code focus]
            }}  // [!code focus]
          >
            {children}
          </OpenfortProvider>
        </OpenfortWagmiBridge>
      </WagmiProvider>
    </QueryClientProvider>
  )
}
```

## EthereumConfig

```ts
export type FeeSponsorshipConfig = string | Record<number, string>

export type EthereumConfig = {
  /** Initial chain ID for the embedded wallet provider.
   * Optional when using OpenfortWagmiBridge — chain is managed by wagmi.
   * Required for SDK-only (no wagmi) mode; defaults to Sepolia if omitted. */
  chainId?: number
  rpcUrls?: Record<number, string>
  /** gas sponsorship ID for gas sponsorship / embedded signer */
  ethereumFeeSponsorshipId?: FeeSponsorshipConfig
  accountType?: AccountTypeEnum
  /** Token addresses for asset inventory (chainId -> Hex[]) */
  assets?: Record<number, Hex[]>
}
```

## The wagmi bridge

When building on Ethereum, Openfort integrates with [wagmi](https://wagmi.sh) through `OpenfortWagmiBridge` and `getDefaultConfig` from `@openfort/react/wagmi`. This bridge synchronizes the Openfort embedded wallet with wagmi's connector system so you can use standard wagmi hooks (`useAccount`, `useWalletClient`, `useSendTransaction`, etc.) with the Openfort wallet.

**Why it's needed:** Openfort manages authentication, key custody, and wallet recovery independently from wagmi. The bridge keeps both systems in sync — when a user authenticates through Openfort and creates a wallet, the bridge registers it as a wagmi connector. When the user signs out, the bridge disconnects the wagmi session. Without it, wagmi hooks would not see the Openfort wallet.

**How it works:**

1. `getDefaultConfig` creates a wagmi config that includes the Openfort connector alongside any external wallets (WalletConnect, injected, etc.).
2. `OpenfortWagmiBridge` wraps your component tree and listens to Openfort auth events. On login, it connects the embedded wallet to wagmi. On logout, it disconnects.
3. Once bridged, `useAccount()` returns the embedded wallet address, `useWalletClient()` returns a signer backed by Openfort, and transaction hooks route through the Openfort provider — including gas sponsorship when configured.

```tsx
import { getDefaultConfig, OpenfortWagmiBridge } from "@openfort/react/wagmi"
import { WagmiProvider, createConfig } from "wagmi"
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
import { baseSepolia } from "viem/chains"

const config = createConfig(
  getDefaultConfig({
    appName: "My App",
    chains: [baseSepolia],
    ssr: true, // set to true for Next.js
  })
)

const queryClient = new QueryClient()

export function Providers({ children }: { children: React.ReactNode }) {
  return (
    <QueryClientProvider client={queryClient}>
      <WagmiProvider config={config}>
        <OpenfortWagmiBridge> {/* [!code focus] */}
          <OpenfortProvider
            publishableKey="YOUR_OPENFORT_PUBLISHABLE_KEY"
            walletConfig={{
              shieldPublishableKey: "YOUR_SHIELD_PUBLISHABLE_KEY",
              ethereum: { chainId: 84532 },
            }}
          >
            {children}
          </OpenfortProvider>
        </OpenfortWagmiBridge> {/* [!code focus] */}
      </WagmiProvider>
    </QueryClientProvider>
  )
}
```

## Setting the account type

Set the `accountType` parameter in `walletConfig.ethereum` to `AccountTypeEnum.EOA`, `AccountTypeEnum.SMART_ACCOUNT`, or `AccountTypeEnum.DELEGATED_ACCOUNT`.

:::info
Learn the differences between EOA, Smart Account, and Delegated Account in [Account types](/docs/products/embedded-wallet/account-types).
:::

```tsx
<OpenfortProvider
  publishableKey="YOUR_OPENFORT_PUBLISHABLE_KEY"
  walletConfig={{
    shieldPublishableKey: "YOUR_SHIELD_PUBLISHABLE_KEY",
    ethereum: { chainId: 84532, accountType: AccountTypeEnum.SMART_ACCOUNT },  // [!code focus]
  }}
>
  {children}
</OpenfortProvider>
```

### EOA wallets on a custom EVM chain

:::info
Building on smart wallets? Check [supported chains](/docs/configuration/chains).
:::

EOA wallets are Ethereum-chain-agnostic in Openfort. Once created, the same address works across every chain — even ones that are not part of the built-in chain list.

:::warning
Set `accountType: AccountTypeEnum.EOA` in `walletConfig.ethereum` for EOA wallets on custom chains.
:::

```tsx
<OpenfortProvider
  publishableKey="YOUR_OPENFORT_PUBLISHABLE_KEY"
  walletConfig={{
    shieldPublishableKey: "YOUR_SHIELD_PUBLISHABLE_KEY",
    ethereum: {
      chainId: 12345,  // [!code focus]
      rpcUrls: { 12345: "https://rpc.custom.xyz" },  // [!code focus]
      accountType: AccountTypeEnum.EOA,  // [!code focus]
    },
  }}
>
  {children}
</OpenfortProvider>
```

:::info
Need external wallets on a custom chain? See [useWalletAuth](/docs/products/embedded-wallet/react/hooks/useWalletAuth).
:::

## Next steps

* [Send a transaction (Ethereum)](/docs/products/embedded-wallet/react/wallet/actions/send-transaction/ethereum)
* [Sign a message (Ethereum)](/docs/products/embedded-wallet/react/wallet/actions/sign-message)
* [Wallet assets](/docs/products/embedded-wallet/react/wallet/assets)
