How telefragged/off-the-grid works
Project type and purpose
• Off the Grid is a Rust-based, multi-crate CLI application plus an off-chain matching service that interacts with the Ergo blockchain.
• Its purpose is to enable users to create, view, redeem, and automatically match “grid trading” orders via a deployed smart contract (grid_multi), while using an Ergo node HTTP API and an external AMM (Spectrum).
File structure
• Root workspace (Cargo.toml, Cargo.lock, flake.nix, Nix, GitHub workflows)
• contracts/grid_multi – on-chain contract source and compiled symbols
• cli/ – main Rust binary crate “off-the-grid”:
• src/main.rs – entry point routing subcommands
• src/commands/… – grid, matcher, scans, tokens, error handling
• src/node/… – HTTP client for node RPC: scan, transactions, wallet, client config
• matcher_config.json, node_config.json, scan_config.json – configuration for matching bot, node connection, scan IDs
• cli/tests – integration/regression tests
• config files & Nix define build and run environments
README for additional insights
• Describes on-chain contract usage, off-chain bots, supported sources (Spectrum), and CLI commands
• Emphasizes two runtime components: the CLI (user-driven) and the matcher bot (automated order matching)
a. Main components
• User (CLI) – issues commands
• off-the-grid binary – houses subcommands: grid, scans, tokens, matcher
• Ergo Node – exposes HTTP RPC (scan UTXOs, wallet, mempool, broadcast tx)
• Blockchain – on-chain state and deployed grid_multi contract
• Spectrum AMM – external liquidity source via Explorer API
• Configuration Store – node_config.json, matcher_config.json, scan_config.json
b. Relationships & interactions
• CLI → Node:
– scans UTXOs (to find existing grid orders, wallet state)
– builds and broadcasts transactions (create/redeem/match orders)
• CLI → Explorer API: fetch token metadata (tokens update command)
• Matcher → Spectrum AMM: fetch current pool prices/reserves to determine match conditions
• Node ↔ Blockchain: maintain UTXOs, execute contract logic when txs are included
• On-chain Contract: enforces correct order matching or owner signature
c. Architectural patterns & design principles
– Separation of on-chain vs off-chain concerns
– Config-driven behavior: decouples deployment details from code
– Single binary with subcommands pattern for different roles (user CLI vs matcher bot)
d. Key technologies & frameworks
– Rust / Cargo / Nix (build environment)
– Ergo node HTTP RPC API
– Ergo contracts written in Sigmastate (contract.es)
– Spectrum AMM Explorer API
– Proptest for regression tests