No description
|
Some checks failed
Build and Test / build (push) Failing after 10s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .forgejo/workflows | ||
| data/daemon | ||
| scripts | ||
| src | ||
| .gitignore | ||
| build.rs | ||
| buildenv.sh | ||
| Cargo.toml | ||
| Makefile | ||
| README.md | ||
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
make build # Release build
make install # Build and install to ~/hero/bin
make installdev # Debug build and install (fastest)
Usage
make run # Build and run the daemon
make dev # Run with debug logging
# Or directly:
mycelium-daemon start
mycelium-daemon status
mycelium-daemon config
mycelium-daemon transfers
mycelium-daemon transfers --status completed
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
make check # Fast code check
make test # Run tests
make fmt # Format code
make lint # Run clippy
make help # Show all available targets
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