How archethic-foundation/bridge-contracts works
Main Components
• EVM Smart Contracts & Ecosystem:
– Contains contracts for HTLC (both signed and chargeable) and liquidity pool mechanisms.
– Includes deployment scripts (in directories like evm/contracts, evm/scripts, evm/test) and configuration files (e.g., hardhat.config.js, .openzeppelin directory).
• Archethic Smart Contracts & Ecosystem:
– Contains similar smart contracts (HTLC, pool, factory contracts) and CLI commands (in directories such as archethic/commands, archethic/contracts, archethic/config.js, and the bridge.js script).
– Provides functions for deploying pools, provisioning HTLCs, and managing secret disclosures.
• Analytics Module:
– The analytics directory includes scripts that collect and process swap-related data from deployed HTLC contracts.
– It also provides views (like the Jade template in analytics/src/views) and controllers for metrics.
• Supporting Infrastructure and Guides:
– Documentation/guides that explain transaction flows and interoperability between EVM and Archethic chains.
– The wormhole_ntt_manager appears to be an additional module that might relate to cross-chain management or further integration.
Relationships and Interactions
• Data and Command Flows:
– Users interact with CLI tools (bridge.js) to deploy, update, or manage contracts on either chain.
– The EVM part uses Hardhat to compile, test, deploy smart contracts which then interact with the Archethic side via defined interfaces (e.g., factory functions and HTLC provisioning).
– Analytics scripts interact with deployed contracts to extract and update swap statistics.
• Interaction Between Components:
– The bridge relies on a contract factory on Archethic to generate HTLC code (via functions like get_chargeable_htlc and get_signed_htlc).
– Once deployed, HTLC contracts on both EVM and Archethic interact via secret revealing or provisioning mechanisms that are critical for atomic swaps.
• Architectural Patterns and Design Principles:
– A layered approach is evident (smart contracts at the blockchain layer, CLI and command scripts in an application layer, and analytics for monitoring).
– Modular separation: the file tree shows distinct directories for analytics, archethic, and evm, promoting separation of concerns.
– Use of CLI commands and configuration files (bridge.js, config.js, ecosystem configuration) for operational management.
Relevant Technologies
• Node.js is the runtime environment for JavaScript-based scripts.
• Hardhat is used for EVM development.
• The use of JSON configuration files for network settings (e.g., the .openzeppelin files, config files in analytics/config).
• Smart contract languages (likely Solidity for EVM and Elixir for Archethic contracts, judging by file conventions like .exs).
• Jade templating for analytics views (indicating a server-side rendered HTML component for metrics).