> 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](/architecture/overview.md) in the main repository for the complete system diagram and deployment checklist.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.evently.market/developers/ux-upgrade.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
