Someone setting up a hardware wallet for the first time, packaging on desk, laptop with wallet interface, afternoon home office light, casual unboxing moment.
Protocols

Web Dapp Integration and Session Lifecycle Management

An operational guide for frontend teams on managing the full WalletConnect session lifecycle—connect, approve, upgrade, disconnect, expire—in production dapps. Covers error handling, reconnection logic, and state synchronization to prevent zombie sessions.
introduction
SESSION LIFECYCLE OPERATIONS

Introduction

An operational framework for frontend teams to manage the full WalletConnect session lifecycle in production dapps, from pairing to expiration.

Web dapp integration with WalletConnect is not a one-time connection event but a continuous lifecycle that must be managed across pairing, approval, upgrade, disconnect, and expiration states. The @walletconnect/sign-client and Web3Modal SDKs provide the primitives, but production dapps must build robust state machines on top of them to handle network interruptions, wallet-side session deletions, and relay reconnection without leaving users stranded with zombie sessions. This page defines the operational patterns for each lifecycle phase and the failure modes that frontend teams must account for.

The session lifecycle begins with a pairing URI generated by the dapp and consumed by the wallet, proceeds through a session proposal and approval handshake that negotiates required and optional namespaces per CAIP-25, and enters a steady state where JSON-RPC requests flow over the relay. The dapp must track the session's expiry timestamp, listen for session_delete and session_update events, and implement reconnection logic that survives page refreshes and wallet app backgrounding. A common failure pattern occurs when a dapp assumes a session is still alive because it holds a local topic string, while the wallet has already deleted the session—resulting in silent request failures that degrade user trust.

Operational rigor requires dapps to synchronize session state with the wallet on every page load by calling getActiveSessions(), to handle session_expire events by cleaning up local state and prompting reconnection, and to implement exponential backoff on relay reconnection to avoid thundering herd problems during infrastructure incidents. Teams should also validate that session upgrade flows—where a wallet adds or removes chains from an existing session—do not introduce namespace mismatches that break subsequent signing requests. Chainscore Labs can review dapp session management implementations for state synchronization edge cases, reconnection resilience, and security risks such as session hijacking through unvalidated topic reuse.

WEB DAPP SESSION MANAGEMENT

Session Lifecycle Quick Facts

Operational facts about the WalletConnect session lifecycle that affect dapp reliability, security, and user experience in production.

AreaWhat changesWho is affectedAction

Session proposal

Dapp sends session_proposal with required namespaces, methods, events, and optional metadata

Frontend teams, wallet developers

Validate that required namespaces match the chains your dapp actually needs; avoid over-requesting permissions

Session approval

Wallet returns session_approve with granted namespaces, accounts, and supported methods

Dapp frontend, QA engineers

Verify that the returned accounts match expected chain IDs and that all required methods are present before proceeding

Session upgrade

Either peer can request additional namespaces, methods, or events via session_update

Dapp developers, wallet SDK integrators

Implement upgrade handlers and test that existing session state is preserved when new capabilities are added

Session expiry

Sessions have a default TTL of 7 days; relay may drop sessions earlier under load

Operations teams, frontend developers

Implement reconnection logic that gracefully handles expired sessions without forcing full disconnect-reconnect UX

Session disconnect

Either peer can initiate disconnect via session_delete; relay emits disconnect event

Dapp frontend, analytics teams

Clean up local session state immediately on disconnect; do not rely solely on relay delivery for state cleanup

Zombie sessions

Dapp holds valid session but wallet has deleted pairing; requests fail silently

Frontend teams, monitoring engineers

Implement heartbeat or ping mechanism to detect stale sessions; surface session health in monitoring dashboards

Reconnection logic

SDK auto-reconnects on page refresh using persisted pairing topic; may fail if relay state is lost

Frontend developers, SREs

Test reconnection under network interruption, browser refresh, and relay failover scenarios; provide manual reconnect fallback

Error handling

JSON-RPC errors, relay errors, and transport failures require distinct handling paths

QA engineers, frontend developers

Map standard error codes to user-facing messages; log structured error data for debugging without exposing sensitive session info

technical-context
SESSION LIFECYCLE MANAGEMENT

The Session State Machine

A precise operational model for the WalletConnect session lifecycle, defining the states, transitions, and failure modes that dapp frontends must handle to prevent zombie sessions and ensure reliable wallet communication.

The WalletConnect session state machine is the core logic governing the lifecycle of a connection between a dapp and a wallet, as defined by the Sign protocol. A session transitions through a finite set of states: proposed, settled, updated, and terminated. The proposed state begins when a dapp initiates a connection via a pairing URI; the settled state is reached upon mutual approval of session parameters, including required namespaces and methods. The updated state reflects any subsequent renegotiation, such as adding a new chain via session_update. The terminated state is reached through an explicit session_delete by either peer or an expiry event. Dapp frontends must model this state machine explicitly to avoid the most common integration failure: a zombie session where the dapp believes a connection is active, but the wallet has already terminated it, leading to silently dropped JSON-RPC requests.

Operationally, the state machine's integrity depends on synchronized state between the dapp, the relay server, and the wallet. The relay acts as a message channel, not a state authority, meaning the dapp and wallet are solely responsible for maintaining a consistent view of the session. A critical risk arises during reconnection logic: if a dapp naively replays a stored session object without verifying its liveness against the wallet, it can enter a permanent error state. The wc_sessionPing method is the standard heartbeat for liveness checks. Builders must implement robust error handling for state transition failures, particularly for session_request calls that fail with error codes like 5001 (session not settled) or 5002 (session not acknowledged), which indicate a state mismatch requiring a full disconnect and re-pairing flow.

For teams managing high-availability dapps, the session state machine must be integrated with the dapp's broader state management layer (e.g., Redux, Zustand) and synchronized with the @walletconnect/sign-client lifecycle hooks. Monitoring should track the rate of unexpected state transitions, such as a high frequency of session_delete events originating from the wallet side, which can signal a poor user experience or a compatibility issue with a specific wallet version. Chainscore Labs can review dapp session management implementations to identify state synchronization gaps, validate reconnection logic against edge cases, and ensure error handling correctly resets the state machine to a clean disconnected state, preventing cascading failures in production environments.

SESSION LIFECYCLE IMPACT

Affected Systems and Teams

Dapp Frontend Teams

Frontend teams are the primary owners of session lifecycle logic. A poorly managed lifecycle directly causes zombie sessions, broken reconnection flows, and user frustration.

Critical responsibilities:

  • Implement robust session_update and session_delete handlers to synchronize local state with the wallet's actual session state.
  • Build reconnection logic that gracefully handles expired or terminated sessions without forcing users to manually disconnect and reconnect.
  • Handle session_proposal errors cleanly, distinguishing between user rejection, timeout, and pairing failure.
  • Synchronize session state across browser tabs to prevent one tab from invalidating a session another tab is actively using.

Action: Audit your Web3Modal or @walletconnect/sign-client integration for edge cases where the dapp believes a session is active but the wallet has already terminated it. Chainscore can review your session management implementation for reliability gaps.

implementation-impact
SESSION MANAGEMENT OPERATIONS

Lifecycle Phase Implementation Guide

A phase-by-phase operational guide for frontend teams to manage WalletConnect session lifecycles reliably in production dapps, preventing zombie sessions and state synchronization failures.

05

Session Expiry and Heartbeat Monitoring

Monitor session expiry timestamps returned in session settlement and track them against a local heartbeat. Sessions have a default expiry of 7 days, but wallets may negotiate shorter durations. Implement a background timer that warns users before a session expires and offers a one-click reconnection. If a session expires, treat it as a terminal state and require a full re-pairing. Do not attempt to extend an expired session silently, as this can mask underlying relay or wallet issues.

PRODUCTION SESSION LIFECYCLE FAILURE ANALYSIS

Session Failure Mode Risk Matrix

Maps common session lifecycle failure modes in production dapps to their operational impact, affected actors, and required remediation actions. Helps frontend teams, wallet developers, and QA engineers prioritize defensive implementation and monitoring.

Failure ModeTrigger ConditionAffected ActorsImpactRemediation Action

Zombie Session

Dapp state retains session after wallet-side disconnect or session expiry

Dapp frontend teams, End users

Dapp shows connected state but signing requests fail silently; users unable to transact

Implement heartbeat checks and sync session state with relay events; clear local state on disconnect acknowledgment

Pairing Stale

Pairing topic expires or is deleted on relay while dapp still references it

Dapp frontend teams, Wallet SDK integrators

New session proposals fail; existing sessions cannot be upgraded or extended

Monitor pairing expiry TTL; re-initiate pairing flow when expiry is within operational window; validate pairing status before session operations

Silent Reconnection Failure

Dapp attempts automatic session restore after page refresh but relay state is lost

Dapp frontend teams, End users

User sees disconnected UI without clear error; session appears active locally but is dead on relay

Implement explicit reconnection with user-facing loading states; surface relay connection status in UI; fall back to fresh connection flow on restore failure

Session Upgrade Rejection

Wallet rejects session upgrade request due to incompatible permissions or unsupported methods

Dapp frontend teams, Wallet developers

Dapp cannot access new chain methods or accounts; feature degradation without clear user messaging

Handle upgrade rejection gracefully with user-facing explanation; verify wallet capability before requesting upgrade; provide fallback UX for degraded sessions

Cross-Chain State Drift

Session approved for multiple chains but wallet switches active chain without dapp awareness

Dapp frontend teams, Multi-chain wallet teams

Dapp sends requests to wrong chain; transaction simulation and gas estimation incorrect

Subscribe to chainChanged events; validate chainId on every request; surface active chain mismatch to user before sending transactions

Relay Connection Loss

WebSocket connection to WalletConnect relay drops due to network instability or relay outage

Dapp frontend teams, Wallet SDK integrators, Infrastructure operators

All session operations hang; no push notifications delivered; user cannot sign or transact

Implement relay health monitoring with reconnect backoff; surface connection status in UI; test failover behavior against relay infrastructure changes

Namespace Mismatch

Dapp requests session with CAIP-2 chain identifiers wallet does not recognize or support

Dapp frontend teams, Wallet developers, Chain integrators

Session proposal rejected or approved with partial namespace; methods unavailable at runtime

Validate namespace support against wallet metadata before proposal; handle partial approval with capability gating in dapp UI

Storage Corruption

Session storage in dapp local state or wallet persistent storage becomes inconsistent

Dapp frontend teams, Wallet SDK integrators

Session metadata lost on page refresh; pairing keys invalid; user forced to reconnect repeatedly

Implement storage integrity checks on session restore; provide clear session reset mechanism; test across browser storage quota limits and mobile OS background eviction

SESSION LIFECYCLE MANAGEMENT

Production Readiness Checklist

A systematic checklist to validate that a production dapp's WalletConnect integration handles the full session lifecycle reliably, from connection and approval through upgrade, disconnect, and expiry. Each item identifies a critical operational risk, the signal that confirms readiness, and the failure mode it prevents.

What to check: The dapp correctly constructs a session proposal with required namespaces, chains, and methods, and handles both approval and rejection responses from the wallet without entering a dead state.

Why it matters: A malformed proposal or unhandled rejection can leave the UI in a perpetual loading state, blocking users from retrying. This is the most common cause of 'connect wallet' failures in production.

Readiness signal: QA test cases pass for: (a) immediate approval, (b) explicit rejection, (c) proposal timeout, and (d) wallet returning an unsupported namespace. The dapp UI recovers to a clean 'disconnected' state in all failure paths.

Chains We Build On

Looking to build on a specific blockchain?

We build smart contracts, DeFi applications, wallets, tokenization platforms, and blockchain infrastructure across the major ecosystems teams choose today. That includes Ethereum, Arbitrum, Optimism, Polygon, Avalanche, Solana, Sui, Aptos, Hedera, Stellar, and NEAR, with support for additional EVM and non-EVM networks based on your product requirements.

EVM ecosystems

  • Ethereum logo
    Ethereum
  • Arbitrum logo
    Arbitrum
  • Optimism logo
    Optimism
  • Polygon logo
    Polygon
  • Avalanche logo
    Avalanche
  • Cronos logo
    Cronos

Non-EVM ecosystems

  • Solana logo
    Solana
  • Sui logo
    Sui
  • Aptos logo
    Aptos
  • Hedera logo
    Hedera
  • Stellar logo
    Stellar
  • NEAR logo
    NEAR

Additional ecosystems

  • Polkadot logo
    Polkadot
  • Cosmos logo
    Cosmos
  • TON logo
    TON
  • Cardano logo
    Cardano
  • Algorand logo
    Algorand
  • Tempo logo
    Tempo

Also available for Base, appchains, custom EVM networks, and cross-chain product architecture.

SESSION LIFECYCLE FAQ

Frequently Asked Questions

Common operational questions from frontend teams managing WalletConnect session lifecycles in production dapps.

A zombie session occurs when the dapp believes a session is active but the wallet has terminated it. To prevent this:

  • Listen for session_delete events on your Sign Client instance and immediately clear local session state. Do not rely solely on user-initiated disconnect buttons.
  • Implement a heartbeat or ping mechanism using session_ping to detect unresponsive wallets. If a wallet fails to respond after a configured threshold, treat the session as expired.
  • On dapp re-initialization, always query the Sign Client for active sessions rather than restoring from localStorage or sessionStorage alone. The client's internal state is the source of truth.
  • Avoid stale state hydration: If you persist session topics to localStorage, validate them against the Sign Client on app load and purge any topics the client does not recognize.

Chainscore can review your session state management logic to identify edge cases that produce zombie sessions.

Trusted by Industry Leaders

Delivering blockchain solutions for 5+ years.

We have partnered with 50+ leading DeFi protocols, NFT ecosystems, and fintech innovators to build secure, scalable, and capital-efficient blockchain products.

Selected Partners & Clients

ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
ChainVote logo
Reax logo
Sokail logo
Swapsicle logo
SyntheX logo
Tekika logo
Telos logo
Zexe logo
“I've been working with Chainscore Labs for last 3+ years, they've consistently delivered with strong ownership across multiple projects. The team is reliable and detail-oriented.”
L
Lee Erswell
CEO, Telos Foundation
how to get started

How to get started?

If you're looking for blockchain integration, ChainScore Labs has 5+ years of experience helping teams build and integrate exchanges, wallets, smart contracts, tokenization solutions, and protocol-connected products, we can help you choose the right path, integrate securely, and get to production faster. Our team consists of experienced blockchain developers and architects who can help you with your blockchain integration needs.

01

Exploration & Strategy

Define your product goals and choose the right blockchain architecture for your use case.

02

Architecture & Design

Design the smart contracts, tokenomics, and security parameters of your system.

03

Development & Integration

Build and integrate with wallets, oracles, and front-end dApps for a seamless experience.

04

Security & Launch

Comprehensive audits followed by a risk-managed mainnet deployment to protect your users.

Start a build

Need a blockchain engineering team?

Send the project context and we will respond with next steps, scope questions, and a practical path to delivery.