> For the complete documentation index, see [llms.txt](https://docs.evently.market/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.evently.market/developers/ux-upgrade.md).

# UX Upgrade — Gasless & Realtime

This document describes the MegaETH UX upgrade shipped to Evently in April 2026.

***

## What Changed

| Before                                          | After                                          |
| ----------------------------------------------- | ---------------------------------------------- |
| Users needed MetaMask / Rabby                   | Email or social login auto-creates a wallet    |
| Users needed ETH for gas                        | All core trades are gasless (sponsored)        |
| Each trade required a wallet popup              | Session keys: sign once, trade up to 100 times |
| UI updated after block confirmation (\~seconds) | UI updates in \~10 ms via MegaETH mini-blocks  |
| Sequential RPC calls (one at a time)            | Multicall batching + WebSocket streaming       |

***

## New Infrastructure Files

### Authentication & Wallets

```
frontend/config/privy.ts           — Privy app config
frontend/app/providers.tsx         — PrivyProvider + WagmiProvider (Privy adapter)
frontend/hooks/useSmartAccount.ts  — Unified wallet hook (smart + EOA fallback)
```

### Gas Sponsorship

```
frontend/lib/paymaster.ts          — Bundler/paymaster clients, function whitelist
```

### Session Keys

```
frontend/hooks/useSessionKeys.ts   — Session lifecycle (start / trade / end)
frontend/components/SessionStatus.tsx — Header session indicator
```

### Real-time

```
frontend/lib/realtime.ts           — MegaETH WebSocket client + eth_sendRawTransactionSync
frontend/hooks/useRealtime.ts      — React hooks for live market data
```

### RPC Performance

```
frontend/lib/multicall.ts          — Multicall3 batching, TTL cache, balanceOfBatch
```

### Security

```
frontend/lib/security.ts           — Rate limiting, spend tracking, spam detection, RPC failover
```

***

## Environment Variables Added

```bash
NEXT_PUBLIC_PRIVY_APP_ID=           # Privy app ID
NEXT_PUBLIC_BUNDLER_RPC=            # ERC-4337 bundler (Pimlico)
NEXT_PUBLIC_PAYMASTER_RPC=          # Paymaster endpoint
NEXT_PUBLIC_PAYMASTER_API_KEY=      # Pimlico API key
NEXT_PUBLIC_PAYMASTER_POLICY_ID=    # Sponsorship policy
NEXT_PUBLIC_MARKETS_ADDRESS=     # EventlyMarkets address (after deployment)
```

***

## Smart Contract Compatibility

`EventlyMarkets.sol` required **zero changes**.

The contract is already fully compatible with:

* ERC-4337 smart accounts (no `tx.origin`, no EOA checks)
* Delegated execution (session keys)
* Smart contract wallets as callers

***

## Full Architecture

See [docs/ARCHITECTURE.md](https://docs.evently.market/architecture/overview.md) in the main repository for the complete system diagram and deployment checklist.
