Network

Deployments & demo mode

How the frontend finds the market contract — and what it does when there isn't one yet.

The LendrMarket contract address isn't hardcoded anywhere in the app. It's read from an environment variable and validated as a proper address before anything on-chain is attempted.

bash
NEXT_PUBLIC_LENDR_MARKET=0x...   # the deployed LendrMarket address for the active network

If that variable is unset, empty, the zero address, or not a well-formed 20-byte hex address, the app treats the market as not yet deployed and falls back to a fully client-side demo mode instead of failing.

Local demo mode

With no market address configured, every action that would otherwise be a contract call instead reads and writes a localStorage key (lendr.market.listings.v1) on the visiting browser. The same state machine applies — open → active → repaid | defaulted, or open → cancelled — and interestOwed uses the identical formula from math.ts, so the demo behaves exactly like the real contract except that nothing is shared across wallets or devices.

  • The book is seeded on first load with a realistic mix of open and active demo listings across several tokenized-stock and memecoin symbols, so /markets never looks empty before a real deployment exists.
  • Every demo action still enforces the same access rules — only the recorded borrower can cancel or repay a listing, only the recorded lender can claim, and claimCollateral still checks now >= startTime + duration against the browser's clock.
  • The UI explicitly labels this state — "Local book · deploy LendrMarket to go on-chain" — so it's never ambiguous whether a given /markets view is reading real chain state.

Demo listings aren't real loans

Nothing in local demo mode moves real tokens or involves a counterparty — it exists purely so the interface has something to render before a LendrMarket contract is deployed and its address configured. Once NEXT_PUBLIC_LENDR_MARKET points at a real deployment, the app switches entirely to on-chain reads and writes and the local book is no longer consulted.