← Protocols
EIP-1102 — Opt-in Account Exposure
Standard / EIP·EVM

EIP-1102 — Opt-in Account Exposure

01Description

Stagnant interface EIP that introduced `eth_requestAccounts` so dapps must obtain explicit user consent before reading wallet addresses. Replaced the auto-injecting `web3.eth.accounts` model and was the predecessor to EIP-1193's full provider API.

02Best for
  • 01wallet connect flows
  • 02browser dapp account access
  • 03permission-gated address reads
  • 04MetaMask / injected provider integration
  • 05legacy provider compatibility
03Install
  • pnpm add viem
  • pnpm add wagmi
  • pnpm add ethers
05Prompt snippet
Always request accounts via `await provider.request({ method: 'eth_requestAccounts' })` (or viem's `requestAddresses` / wagmi's `useConnect`) — never read `provider.selectedAddress` first, since that returns `null` until consent is granted. Treat the returned `Promise<string[]>` as a permission grant: cache the result, but re-call on `accountsChanged` and on dapp reload (per-origin permission persists in most wallets). Handle the user-rejection error code `4001` (EIP-1193 unified error) and the older `-32603` from legacy MetaMask. EIP-1102 was superseded by EIP-1193 (full provider RPC) and EIP-2255 (granular permissions); modern code should target the unified EIP-1193 / EIP-6963 flow and treat `eth_requestAccounts` as the consent primitive within that surface.
06Gotchas
  • EIP-1102 is Stagnant and was folded into EIP-1193 — the legacy `ethereum.enable()` shim still exists in some wallets but is deprecated; always use `request({ method: 'eth_requestAccounts' })` so you get the EIP-1193 promise/error semantics.
  • Do not call `eth_requestAccounts` at page load — modern wallets surface a popup, and unrequested popups are blocked or annoy users; trigger only from a user-initiated event (button click).
  • `eth_accounts` (without `request`) returns `[]` until permission is granted — many bugs come from gating UI on `eth_accounts.length > 0` and never prompting; gate on a 'Connect' button that calls `eth_requestAccounts`.
  • Permission revocation is wallet-side only — there is no `eth_revokeAccounts`; rely on EIP-2255 `wallet_revokePermissions` (where supported) or instruct users to disconnect from the wallet UI.
  • Multi-account wallets return all unlocked addresses but the dapp typically uses index 0 — listen for `accountsChanged` and re-render; assuming a stable single account causes silent state corruption when the user switches.
  • With EIP-6963 multi-provider discovery, `window.ethereum` is unreliable — prefer iterating announced providers and calling `eth_requestAccounts` on the user-selected one rather than the global injection.
07Alternatives