Skip to content

docs: add Sepolia ↔ Miden bridging tutorial via Epoch (+ examples/bridging-app)#199

Open
Keinberger wants to merge 2 commits into
mainfrom
feat/web-client-bridging-epoch-tutorial
Open

docs: add Sepolia ↔ Miden bridging tutorial via Epoch (+ examples/bridging-app)#199
Keinberger wants to merge 2 commits into
mainfrom
feat/web-client-bridging-epoch-tutorial

Conversation

@Keinberger
Copy link
Copy Markdown
Collaborator

@Keinberger Keinberger commented May 18, 2026

Summary

This PR ships a single-page web-client tutorial (docs/src/web-client/bridging_with_epoch_tutorial.md) covering Miden↔Sepolia bridging via the Epoch protocol intent SDK, plus a runnable Vite + React reference app under examples/bridging-app/ that the tutorial's snippets paste-verify against.

The tutorial is framed as a guided tour of the reference app: clone it, run it, then read the steps as annotations on the integration points you'd port into your own Miden frontend. Every fenced code block is byte-identical to a slice of examples/bridging-app/src/..., with a preceding **From <file> (lines X–Y):** prose line plus an HTML <!-- source: ... --> comment that the agent task-workflow verifier checks against the real source. Both directions were exercised live on Sepolia + Miden testnet through a wallet-enabled Playwright MCP browser — forward: EVM tx 0xe8d4eb1b…1112 status: success with P2IDE note 0xc03ec01…cc798 consumed on Miden; reverse: Sepolia compact-deposit tx 0xe0e7f415…a063ad86 with Miden P2ID note 0x5d577237…612c5378 delivered to the recipient wallet.

Companion sidebar + Bridging DocCard in 0xMiden/docs#297.

Key Changes

  • Tutorial with four steps — SDK wiring, Miden → EVM bridge, EVM → Miden bridge, and how the Miden Wallet consumes the delivered P2ID note — plus eleven inherited Epoch pitfalls and an eleven-method EpochIntentSDK API reference card sourced to dist/index.d.ts line ranges.
  • examples/bridging-app/ forked from epochprotocol/miden-integration-example@efc3a690 with bridging-specific adaptations: midenReclaimHeight computed at the call site as currentMidenBlock + 1000 (was a literal upstream), env-driven VITE_RAINBOWKIT_PROJECT_ID + VITE_ALLOCATOR_URL, auto-derived Miden faucet ID for known tokens, shared MidenWalletAdapterProvider context so the wallet's requestAssets() popup fires once per page load instead of per consumer, lazy-mount-then-keep tabs so an in-flight withdraw quote survives a tab switch, and an informational WithdrawConsume panel that points readers at the auto-consumed P2ID note on Midenscan.
  • Bigint-safe Miden balance formatting in the Source-asset dropdown and Balance: label — uses viem's formatUnits against the faucet's decimals instead of Number(amount) (the raw base-unit display was a real bug surfaced live by a fresh-reader pass through the tutorial).
  • Browser title Miden x Epoch Bridge replacing the scaffold default.
  • 38 Vitest tests across the formatter helper, the WithdrawConsume panel, and the IntentForm balance render; tsc -b --noEmit, vite build, prettier --check "**/*.md", yarn lint, the docs npm run build:dev, and the snippet verifier all clean.

Out of scope

  • No Agglayer tutorial — the tutorial's "When to use Epoch vs Agglayer" disclaimer points at protocol/crates/miden-agglayer/SPEC.md. A web-Agglayer tutorial will be its own PR after a feasibility pass.

Open Questions

  1. Tutorial word count: the tutorial sits at 2,500 words exactly (the documented band ceiling). Happy to trim a couple of pitfalls or fold the API reference card into a collapsed <details> if you'd prefer breathing room.
  2. DocCard placement: the companion docs PR puts Bridging as the 4th card in the tutorials index. Happy to move it earlier in the order or rename it if Brian wants a different IA.

Reviewers: Brian (docs IA), an Epoch team rep for technical accuracy, Keinberger for voice.

…dging-app)

Adds a single-page web-client tutorial covering Miden→EVM and EVM→Miden
bridging through the Epoch protocol intent SDK, plus a runnable Vite + React
reference app under examples/bridging-app/ that the tutorial's code blocks
paste-verify against (a snippet check enforces byte-identity).

The example app is forked from epochprotocol/miden-integration-example@efc3a690
with bridging-specific adaptations: the '1000' reclaim-height literal replaced
with a runtime currentMidenBlock + 1000 computation, the dead wagmi Miden chain
placeholder + no-op midenClient removed, the RainbowKit projectId made
env-driven (with a setup screen instead of a blank-page crash when unset), the
WithdrawForm token decimals corrected to 18, and the general-purpose Miden
wallet UI stripped to keep the example focused on bridging.

The tutorial covers wiring the SDK against a wagmi walletClient with the Miden
virtual chain id override, the Miden→EVM four-stage pipeline (getTaskData →
getIntentQuote → solveIntent → polling), the EVM→Miden reverse direction
through Epoch's Compact contract on Sepolia, an 11-method API reference card,
and the inherited Epoch integration pitfalls. It stays within the 2,000-2,500
word band and ships unit coverage for the epoch-bridge task-data builders.
feat(bridging-app): reference-app-walkthrough reframe, bigint-safe Miden balance, info-panel consume
@BrianSeong99
Copy link
Copy Markdown
Contributor

Did a fresh pass against the latest PR head and the current Epoch materials, some feedbacks!

1 Status polling should be destination-chain aware.

The latest Epoch example does not treat “first non-Miden status row” as the final EVM settlement. It filters status rows to the actual destination chain, waits while any destination-chain row is still pending, then takes the last destination-chain success.

This PR currently does:

  • useIntentFlowStatus.ts: statuses.find((s) => Number(s.chainId) !== MIDEN_CHAIN_ID)
  • IntentForm.tsx: evmStatuses.find(...)

That can pick up an internal Compact/SIO row instead of the user’s destination-chain settlement. The upstream example explicitly calls this out because SIO can surface a prior-step success alongside an in-flight destination-chain tx.

Can we port the destination-chain-aware logic from the latest Epoch example into this PR? Just to make sure dvelopers/agents are aware of potential unsettled transctions in the list.

2 The midenConsumed wording doesn’t match the app code.

The Epoch GitBook’s raw /miden/status/... example mentions midenConsumed, but this app uses sdk.getIntentStatus(...), which returns IntentTransactionStatus[]. The local IntentFlowStatus type has evmCompleted, midenTxId, midenStatus, and midenNoteId, but no midenConsumed.

So this sentence should either be rewritten to match the SDK-row flow, or the app should actually call/type the raw /miden/status endpoint if midenConsumed is the intended success signal.

3 Please remove internal Epoch implementation names from public comments.

There are a few public source comments that mention internal service names / source paths, e.g. dex-solver inventory, epoch-sio/src/.... Since this is a public Miden tutorial, I’d keep the wording at the protocol/API level: “allocator”, “Epoch status API”, “Miden virtual chain id”, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants