How acgodson/crownie-etherlink works
Project Type and Purpose
• Crownie is a hybrid application combining:
• Smart Contracts (Escrow Factory, Resolver, HTLC escrows) on the Etherlink blockchain
• A Browser Extension (“Crownie Extension”) acting as an off-chain live-meeting relayer
• A Public Web Interface (marketing site + dashboard)
• Purpose: Enable secure, coordinated atomic swaps using hash-timelocked contracts and social coordination during live meetings.
File Structure
• Top-Level:
• pnpm-workspace.yaml indicates a monorepo managed by pnpm.
• crownie-swap likely holds smart contract code and tests.
• apps/extension:
• Source code (React + TypeScript) for the browser extension
• Subfolders: background, content, popup, components, stores, utils
• Scripts to build and package the extension
• apps/web-interface:
• React + TypeScript marketing site and dashboard
• Uses Vite, Tailwind, custom hooks (e.g., useFusionBridge) to query chain data
• CI/CD:
• .github/workflows/build-extension.yml for building and releasing the extension
Extract README Insights
• Core on-chain components:
1. Escrow Factory Contract
2. Resolver Contract
3. HTLC Escrows
• Off-chain: Crownie Extension with “Live Meeting Relayer” and “Secret Monitor & Revelation”
• Intent-based architecture on Etherlink (inspired by 1inch Fusion+)
Main Components & Their Responsibilities
a. Blockchain Layer (Etherlink Chain):
• Escrow Factory Contract (deploys HTLC escrows)
• Resolver Contract (orchestrates swap logic)
• HTLC Escrows (source & destination locks)
b. Crownie Browser Extension:
• Content Script: injects into meeting pages, listens for events
• Background Script: manages state, communicates with the blockchain via web3 provider
• Popup UI & Offscreen Pages: user dashboard (Meeting History, Settings)
• Auth Flow: OAuth callback pages + auth injector
• Stores: authStore, meetingStore
• Utilities: chain-interaction (env.ts), secret monitor
c. Public Web Interface:
• Landing pages (hero, solution, problem sections)
• React components consuming on-chain data via useFusionBridge hook
• No custodial backend—direct calls to Etherlink RPC or 1inch-style API
d. Build & Deployment:
• Vite configs for each SPA
• Packaging scripts under apps/extension/scripts
• GitHub Actions workflow for CI/CD
Relationships and Interactions
• User opens browser extension → Extension UI calls background script
• Background script interacts with Etherlink via Web3 (RPC/Injected provider)
• Content script bridges live meeting events to background script
• Background script orchestrates HTLC creation and monitors on-chain events
• On secret revelation, background emits instructions back to content script
• Public web interface uses RPC or bridging API to display swap statistics / documentation
Architectural Patterns & Design Principles
• Separation of concerns: UI (popup, offscreen page), networking (background), DOM injection (content)
• Event-driven flows: messages between content ↔ background ↔ UI
• Monorepo modularization: contracts, extension, web app share types/config
• Intent-based swap pipeline (inspired by Fusion+): abstract intent → HTLC deployment → secret revelation