EIPs
EIP-3085 — wallet_addEthereumChain
Asks the wallet to add a chain definition (chain ID, RPC URL, native currency, explorer) to its known-chain list. The user sees the proposal in a popup; on approval the chain becomes selectable.
import { eip155_1 } from "@ethernauta/chain/eip155-1";
import { UintSchema } from "@ethernauta/core";
import { wallet_addEthereumChain } from "@ethernauta/eip/3085";
import type { Provider } from "@ethernauta/eip/1193";
import { create_provider, encode_chain_id } from "@ethernauta/transport";
import { parse } from "valibot";
const CHAIN_ID = encode_chain_id({ namespace: "eip155", reference: eip155_1.chainId });
declare const provider: Provider; // see /eips/6963 for discovery
const { signer } = create_provider(provider);
await wallet_addEthereumChain([
{
chainId: parse(UintSchema, "0x2105"),
chainName: "Base",
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
rpcUrls: ["https://mainnet.base.org"],
blockExplorerUrls: ["https://basescan.org"],
},
])(signer({ chain_id: CHAIN_ID })); Surface
| Export | Type | Purpose |
|---|---|---|
wallet_add_ethereum_chain | Signable<null> | Submit the chain proposal. |
AddEthereumChainParameter, AddEthereumChainParameters | types | Single + array shapes. |
| schemas for both above |
Why a dapp would call this
L2s, sidechains, and testnets that aren’t in the wallet’s built-in registry need to be added before they can be switched to with wallet_switchEthereumChain. The typical pattern: try wallet_switchEthereumChain first; on a 4902 unrecognized_chain error, fall through to wallet_addEthereumChain then retry the switch.
See also
- EIP-3326 — switch to an added chain.
- @ethernauta/chain — Ethernauta’s built-in registry.
- Wallet → add-chain view.