Wallet Integration for Web Apps: Signatures, Sessions and the UX Traps
'Connect wallet' is a button; wallet auth is a system. Sign-in with Ethereum done right, the session model that survives a page refresh, and the chain-switching flow that loses users at the worst moment.

The wallet connection flow is the front door of every dApp, and it is where most of them bleed users. A popup appears, another popup appears, the user is on the wrong network, the signature request looks like a phishing attempt, and the person who was ready to deposit has closed the tab.
The technical pieces are simple. The system around them — sessions, chain handling, error recovery — is where the engineering actually lives.
Connect is not authenticate
Connecting a wallet proves the user has a wallet. It does not prove they control it to your backend. Anyone can call eth_requestAccounts and claim any address in the UI. Authentication requires a signature, and the standard is Sign-In with Ethereum (EIP-4361): the user signs a structured message containing your domain, a nonce, and a timestamp.
app.example.com wants you to sign in with your Ethereum account:
0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18
URI: https://app.example.com
Version: 1
Chain ID: 1
Nonce: 8f3a2b1c
Issued At: 2026-10-08T12:00:00ZThe server verifies the signature recovers to the claimed address, checks the nonce is fresh and the domain matches, and only then issues a session. The nonce is the anti-replay piece: generate it server-side, store it, use it once, delete it.
import { verifyMessage } from class="text-code-string">"viem";
const valid = await verifyMessage({
address: claimedAddress,
message: siweMessage,
signature,
});
if (!valid || message.nonce !== storedNonce) throw new Error(class="text-code-string">"auth failed");
await createSession(claimedAddress);Sessions: do not make them sign twice
The signature proves control once. It should not be required on every page load — yet plenty of dApps effectively do this by keeping "logged in" state in memory and losing it on refresh.
Issue a normal session after the signature verifies: an httpOnly cookie, a server-side session store, the same machinery as any web app. The wallet is the credential; the session is the session. Reconnecting the wallet on refresh should restore the session silently if the cookie is valid, and only ask for a new signature when the session has expired.
One subtlety: if the user switches accounts in their wallet, detect it (accountsChanged event) and invalidate the session. Serving account A's dashboard to account B's wallet is a confusing experience at best and a data leak at worst.
The chain-switching trap
Half of all wallet UX failures are network mismatches. The user is on mainnet; your app is on an L2. The amateur flow: transaction fails with a cryptic error. The professional flow:
1. Detect the connected chain on load, before any action. 2. If it is wrong, show the requirement in your UI — "This app runs on Arbitrum" — with a switch button. 3. Call wallet_switchEthereumChain; if the chain is not in the user's wallet, catch error 4902 and call wallet_addEthereumChain with the network parameters.
try {
await walletClient.switchChain({ id: arbitrum.id });
} catch (e) {
if (e.code === 4902) {
await walletClient.addChain({ chain: arbitrum });
}
}Listen for chainChanged and react — a user who switches networks mid-session should see the UI adapt, not a stale page about to produce a failed transaction.
The errors users actually hit
- User rejected the request. Not an error — a decision. Show a calm "connection cancelled" state with a retry button, not a red banner.
- Insufficient funds for gas. Check the native balance before prompting the transaction, and say so in plain language.
- The transaction is pending for minutes. Show the pending state with a link to the explorer. Silence is what makes users resubmit and pay twice.
The principle
Wallet UX fails when the app treats the wallet as a login button instead of a stateful external system with its own accounts, networks, and failure modes. Handle the events, respect the rejections, verify the signatures server-side, and the front door stops leaking users.
Paj Digital Labs
The engineering journal of Paj Digital Solutions — hosting, server infrastructure and web engineering, written by the people who run the servers.
Related reading

Solana Transaction Operations: Blockhash Expiry, Commitments and Retries
A timed-out submission may still have landed. Track signatures, validity windows and commitment levels before rebuilding a transaction and risking a duplicate business action.

Blockchain Dependency Incidents: Circuit Breakers for RPC and Indexer Failures
A stale indexer and an unavailable RPC need different responses. Monitor data freshness, stop unsafe writes and preserve transaction tracking when chain infrastructure degrades.

ERC-4337 Account Abstraction: Bundlers, Paymasters and the Product Boundary
Smart accounts can improve recovery and transaction UX, but their dependencies need explicit limits. Understand user operations, sponsorship and deployed versions before treating gasless as free.