No description
Mycelium Network daemon that monitors: - TFT to Spore token migration events - Network health and sync status - Pending migrations across the network Features: - Schema-driven code generation with OSIS - HTTP monitoring API at /api/monitor/ - Configurable poll interval and endpoints - Auto-reconnect with exponential backoff 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| data/daemon | ||
| src | ||
| .gitignore | ||
| build.rs | ||
| build.sh | ||
| Cargo.toml | ||
| README.md | ||
| run.sh | ||
Mycelium Daemon
Monitors TFChain escrow wallet for incoming TFT transfers and mints equivalent Spore tokens on HeroLedger.
Overview
The Mycelium Daemon is a background service that:
- Monitors TFChain: Watches for incoming TFT transfers to the designated escrow wallet
- Tracks Migrations: Records all detected transfers with their confirmation status
- Mints Spore Tokens: Once transfers are confirmed, mints equivalent Spore tokens on HeroLedger (NEAR-based)
- Maintains State: Uses OSIS for persistent storage of transfer records and configuration
Architecture
TFChain (TFT) ──────────────────┐
│
User sends TFT to ──────┼──> Daemon detects transfer
escrow wallet │
│
▼
┌───────────────┐
│ OSIS Store │
│ (transfers, │
│ config) │
└───────────────┘
│
▼
┌───────────────┐
│ HeroLedger │
│ (SPORE mint) │
└───────────────┘
Building
./build.sh
Or manually:
cargo build --release
Usage
Start the daemon
./run.sh
Or manually:
./target/release/mycelium-daemon start
Check status
./target/release/mycelium-daemon status
View configuration
./target/release/mycelium-daemon config
List transfers
# All transfers
./target/release/mycelium-daemon transfers
# Filter by status
./target/release/mycelium-daemon transfers --status completed
# With pagination
./target/release/mycelium-daemon transfers --offset 0 --limit 50
Configuration
The daemon stores its configuration in the OSIS database. Default values:
| Setting | Default | Description |
|---|---|---|
| escrow_wallet | 5GrwvaEF... |
TFChain address to monitor |
| tfchain_url | wss://tfchain.grid.tf:443 |
TFChain WebSocket endpoint |
| heroledger_url | https://rpc.mainnet.near.org |
NEAR RPC endpoint |
| spore_contract | spore.near |
SPORE token contract |
| exchange_rate | 1.5 SPORE/TFT | Conversion rate (stored as nanoSpore) |
| min_confirmations | 12 | Blocks before processing |
| poll_interval_ms | 10000 | Check frequency |
Transfer Status Flow
Detected → Confirmed → Minting → Completed
↓
Failed (can be retried)
Development
Schema
The daemon uses OSIS schemas defined in src/domains/daemon/monitor.oschema:
MonitoredTransfer: Tracks individual TFT→SPORE migrationsDaemonConfig: Global daemon configurationDaemonStats: Runtime statistics
Generated Code
Code is auto-generated from schemas during build. The generated modules are in src/code/.
License
Apache-2.0