Status: Architecture + skeleton code
Target: Native Rust + WebVM (cheerpx/sel4) compatible
Deployment: Aptos mainnet with sel4 kernel support
┌──────────────────────────────────────────────────────────┐
│ Rust Service (native/webvm) │
│ ┌────────────────────────────────────────────────────┐ │
│ │ Axum HTTP Router + Tower Middleware │ │
│ ├────────────────────────────────────────────────────┤ │
│ │ /health → Health check │ │
│ │ /contracts/:name → Fetch Move contract │ │
│ │ /subscribe → Create Flowglad billing │ │
│ │ /snipe → Execute market snipe │ │
│ │ /subscription/:user_id → Check quota/balance │ │
│ └────────────────────────────────────────────────────┘ │
│ ↓ ↓ ↓ │
└──────┬──────────────────┬──────────────────┬──────────────┘
↓ ↓ ↓
┌────────────┐ ┌──────────────┐ ┌─────────────┐
│ AptosClient│ │ FlowgladBill │ │ SnipeMarket │
├────────────┤ ├──────────────┤ ├─────────────┤
│ get_contract │ create_sub │ │ determine │
│ call_contract │ get_balance │ │ winner │
│ get_resources │ poll_payment │ │ get_history │
└────────────┘ └──────────────┘ └─────────────┘
↓ ↓ ↓
┌────────────┐ ┌──────────────┐ ┌─────────────┐
│ RPC: Aptos │ │ RPC: Flowglad│ │ On-chain │
│ mainnet │ │ webhook poll │ │ DuckDB │
└────────────┘ └──────────────┘ └─────────────┘
// Create 69 snipes/month subscription
POST /subscribe
{
"user_id": "alice",
"snipes_per_month": 69,
"payment_method": "stripe"
}
→ { "checkout_url": "https://checkout.flowglad.io/..." }
// Polling for payment confirmation
async poll_payment_status(sub_id) → "completed" | "pending"GET /contracts/snipe_core
→ {
"name": "snipe_core",
"address": "0x1::snipe_core",
"functions": [
{"name": "create", "params": ["creator", "target", "duration"]},
{"name": "commit", "params": ["signer", "snipe_id", "hash"]},
{"name": "reveal", "params": ["signer", "snipe_id", "amount"]},
{"name": "resolve", "params": ["signer", "snipe_id", "actual"]}
]
}
// Call Move entry function
POST /call
{
"module": "snipe_core",
"function": "create",
"args": ["my-target", "86400"]
}
→ { "tx_id": "0xabc123..." }// Determine winner at interaction time by bandwidth comparison
POST /snipe
{
"user_id": "alice",
"target_id": "bob",
"color_bandwidth": {
"red": 0.8,
"green": 0.7,
"blue": 0.6,
"extra_spectral": 0.5 // Optional: UV/IR/polarization
}
}
→ {
"winner": "alice", // Higher total bandwidth
"loser": "bob",
"bandwidth_diff": 0.42,
"snipe_used": true // Decremented from quota
}cd flowglad-rs-aptos-webvm
cargo build --release
cargo run --release
# Listens on http://0.0.0.0:3000# Compile to wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknown --features webvm
# Package for cheerpx
cd cheerpx
./build-webvm.sh ../target/wasm32-unknown-unknown/release/flowglad_aptos_webvm.wasm
# Boot sel4 kernel + webvm runtime
./boot.sh# Build with sel4 kernel support
cargo build --features sel4-kernel
# Link with sel4 runtime
ld -T sel4_linker.ld \
flowglad_aptos_webvm.o \
/path/to/sel4/libsel4.a \
-o flowglad_aptos.elfcurl -X POST http://localhost:3000/subscribe \
-H "Content-Type: application/json" \
-d '{
"user_id": "alice",
"snipes_per_month": 69,
"payment_method": "stripe"
}'curl -X POST http://localhost:3000/snipe \
-H "Content-Type: application/json" \
-d '{
"user_id": "alice",
"target_id": "bob",
"color_bandwidth": {
"red": 0.9,
"green": 0.8,
"blue": 0.7,
"extra_spectral": 0.6
}
}'curl http://localhost:3000/subscription/alicecurl http://localhost:3000/contracts/snipe_corecargo test
cargo test -- --nocapture # With println output
cargo test flowglad # Filter tests| Component | RPC Endpoint | Feature |
|---|---|---|
| Aptos | https://fullnode.mainnet.aptoslabs.com |
Move contract calls |
| Flowglad | Custom polling URL | Webhook-free billing |
| DuckDB | Local/remote ledger | Market history + payouts |
| sel4 | Kernel syscalls | VM isolation |
| cheerpx | WebVM runtime | Browser sandboxing |
aptos-society- Multiverse finance (GayMove contracts)aptos-agent- MCP Aptos interactionaptos-trading- Alpha executor tradingflowglad-integration- Billing pattern referencesel4-boxxy- sel4 kernel integration
src/main.rs- HTTP router + server bootstrapsrc/market.rs- SnipeMarket + ColorBandwidthsrc/aptos_client.rs- Aptos RPC clientsrc/flowglad_billing.rs- Subscription + pollingCargo.toml- Dependencies
Next steps:
- Implement real Aptos RPC calls (requires aptos-sdk setup)
- Integrate Flowglad polling endpoint (requires API key)
- Connect DuckDB ledger for market history
- Test sel4 kernel integration with cheerpx
- Deploy to Aptos mainnet via validator network