Integrate hero_ledger for on-chain token payments #50
Labels
No labels
meeting-notes
meeting-sensitive
meeting-transcript
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
coopcloud_code/home#50
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Replace the in-memory wallet (UserPersistence JSON files) with hero_ledger's on-chain token system. Users get real SPORE/USDH balances, transfers are on-chain, exchange rates come from SPOREX.
Architecture
The gateway client is an HTTP client — no container needed. Just add the crate dependency and connect.
Reference
clients/gateway/— Rust SDK with reqwest HTTP, multi-URL failovercall_public(read, no auth),call_write(signed transactions)Gateway client methods we need
tokens_balance("SPORE", account_id)WalletManager::get_balance()tokens_transfer("SPORE", receiver, amount)WalletManager::transfer_credits()tokens_metadata("SPORE")WalletManager::get_wallet_info()tokens_total_supply("SPORE")marketplace_list_listings()marketplace_get_listing(id)Contracts available
Tasks
Backend
hero_ledger_gatewaydependency to Cargo.tomlsrc/services/impl_ledger/moduleWalletManagertrait usingGatewayClient:get_balance()→tokens_balance("SPORE", user_account_id)get_transactions()→ query on-chain TX historycredit()→tokens_transfer()from marketplace accounttransfer_credits()→tokens_transfer()peer-to-peerbuy_credits()→ fiat payment → mint/transfer SPOREPoolManagertrait using SPOREX contract:get_pools()→ exchange pairsexchange_tokens()→ SPOREX swapHERO_LEDGER_NETWORK=devenv var, branding.toml[ledger]sectionAPP_WALLET_BACKEND=ledger(default stayslocalfor dev)SPA Frontend
Testing
Key decisions
APP_WALLET_BACKEND=local(OSIS, dev) vsledger(on-chain, prod)— mik-tf
Progress: core integration complete
Done (L1-L7)
Verified
Remaining
To activate: set
APP_WALLET_BACKEND=ledgerin the container env.— mik-tf
Status update — gateway is live, 3 fixes needed to connect
Verified
https://ledger.dev.projectmycelium.com/rpcmarketplace.listListings→ 6 listingsx-gateway-account-idheaderFixes needed
/rpc. Fix default URL or append path in client.GatewayClient.set_credentials()never called. Need marketplace operator account + signing key for token operations.APP_WALLET_BACKEND=ledger+HERO_LEDGER_GATEWAY_URL=https://ledger.dev.projectmycelium.com/rpcon dev VM.hero_compute (#51)
— mik-tf
Architectural direction: hero_ledger IS the marketplace backend
Confirmed with Scott Yeager (hero_ledger maintainer) and Mik:
What this means
hero_ledger is not just a payment rail — it is the single source of truth for all marketplace economic data:
marketplace.*contracttokens.*contractOSIS remains for session/local state only:
Updated task list
Original tasks L1-L7 (wallet) are done. New tasks for full integration:
ProductCatalogtrait backed bymarketplace.listListings/marketplace.getListingPoolManagertrait backed by SPOREX contracttests/ledger_integration.sh)What doesn't change
/api/products,/api/wallet/balance, etc.)— mik-tf
Account creation flow documented
How marketplace creates hero_ledger accounts
account.activatewith public_key hex, domain (e.g.username.mycelium), emailImportant: proper ed25519 keypair
The
public_keysent toaccount.activatemust be the real ed25519 public key derived from the secret seed — NOT a random hex string. Without the matching secret key, you can't sign transactions for that account.For the marketplace integration
When a user registers on the marketplace:
account.activate→ creates hero_ledger accountEnv vars for marketplace operator account
Account activated on devnet.
— mik-tf
Full auth flow working — SPORE balance queried on-chain
Account
0a431196...4f0205(mktplace3.mycelium) activated and tested:Key finding: params key order matters
The gateway verifies signatures using alphabetical key order in the params JSON. The Rust
GatewayClienthandles this via serde_json, but manual signing must use sorted keys.What works end-to-end
Balance is 0 SPORE (freshly created). Waiting for test tokens.
— mik-tf
mik-tf referenced this issue2026-04-01 17:28:03 +00:00
Code complete — impl_ledger/wallet_manager.rs and impl_ledger/product_catalog.rs merged.
Blocked on SPORE tokens from Scott (hero_ledger#41). Consolidated into mycelium_code/home#55
— mik-tf