lobstercove

MoltChain — Agent Skill Book

*Last updated: June 2025*

lobstercove 2 Updated 2mo ago
GitHub

Install

npx skillscat add lobstercove/moltchain

Install via the SkillsCat registry.

SKILL.md

MoltChain — Agent Skill Book

Complete operational reference for autonomous agents on MoltChain.
Covers every contract, RPC endpoint, WebSocket subscription, CLI command, transaction type,
wallet operation, DEX strategy, identity system, achievement, ZK privacy flow, and deployment procedure.


Table of Contents

  1. Quick Reference
  2. Architecture
  3. Native Transaction Types
  4. Contract Call Format
  5. Contract Surface (29 Contracts)
  6. DEX Contracts — Full Opcode Reference
  7. MoltyID Identity System
  8. Achievement System (90+ Achievements)
  9. Staking & ReefStake
  10. ZK Shielded Transactions
  11. RPC Methods
  12. REST API Endpoints
  13. WebSocket Subscriptions
  14. JavaScript SDK
  15. Wallet Operations
  16. CLI Reference
  17. Validator Operations
  18. Contract Development
  19. Build & Test

1. Quick Reference

Property Value
Chain MoltChain (custom L1)
Consensus Tendermint-style BFT (PoS with contributory stake)
Block time ~800ms heartbeat, ~200ms with transactions (adaptive)
Native token MOLT (1 MOLT = 1 000 000 000 shells)
Signing Ed25519
Smart contracts WASM (Rust → wasm32-unknown-unknown)
ZK proofs Groth16 over BN254 (Poseidon hashing)
RPC JSON-RPC 2.0 on port 8899
Solana compat RPC POST /solana on port 8899
EVM compat RPC POST /evm on port 8899
WebSocket Port 8900
Explorer Port 3001
DEX Port 8080
Wallet Port 3000
Faucet Port 9100
Custody Port 9105
Monitoring Port 9100 (Prometheus metrics)
Contracts deployed at genesis 29
Trading pairs at genesis 7
Total RPC methods ~166 (JSON-RPC) + ~65 REST routes
Total contract opcodes 147 (DEX) + named exports (22 contracts)
Achievements 90+ auto-detected

Production Endpoints

Service URL Network
RPC (Mainnet) https://rpc.moltchain.network Mainnet
WebSocket (Mainnet) wss://ws.moltchain.network Mainnet
RPC (Testnet) https://testnet-rpc.moltchain.network Testnet
WebSocket (Testnet) wss://testnet-ws.moltchain.network Testnet
Custody Bridge https://custody.moltchain.network
Faucet https://faucet.moltchain.network Testnet
Explorer https://explorer.moltchain.network
DEX (ClawSwap) https://dex.moltchain.network
Wallet https://wallet.moltchain.network
Developer Portal https://developers.moltchain.network
Marketplace https://marketplace.moltchain.network
Programs IDE https://programs.moltchain.network
Monitoring https://monitoring.moltchain.network

Official Links

Resource URL
Website https://moltchain.network
Documentation https://developers.moltchain.network
GitHub https://github.com/lobstercove/moltchain
Email hello@moltchain.network
Discord https://discord.gg/gkQmsHXRXp
X https://x.com/MoltChainHQ
Telegram https://t.me/moltchainhq

Seed Validators

Region Host
US (Virginia) seed-01.moltchain.network
EU (France) seed-02.moltchain.network
SEA (Singapore) seed-03.moltchain.network

2. Architecture

Core Components

Component Crate Purpose
Core moltchain-core State machine, accounts, transactions, WASM VM, ZK verifier, consensus
RPC moltchain-rpc JSON-RPC server, REST API, WebSocket subscriptions
P2P moltchain-p2p Gossip protocol, block propagation, validator announce
Validator moltchain-validator Block production, slot scheduling, auto-update
CLI moltchain-cli Command-line wallet tool
Compiler moltchain-compiler Rust → WASM contract compilation pipeline
Custody moltchain-custody Multi-signature custody with threshold signing, bridge deposits/withdrawals

Transaction Format

Transaction {
    from: [u8; 32],           // Ed25519 public key
    recent_blockhash: [u8; 32],
    instructions: Vec<Instruction>,
    signatures: Vec<Signature>,   // Ed25519 64-byte signatures
}

Instruction {
    program_id: [u8; 32],     // System (all zeros) or Contract (all 0xFF) or specific program
    accounts: Vec<[u8; 32]>,  // Account pubkeys involved
    data: Vec<u8>,            // Opcode + args (system) or JSON (contract)
}

Wire format: Bincode serialization → base64 for RPC transport.
Routing: First-byte heuristic distinguishes bincode vs JSON payloads.

Special Program IDs

Program Address Description
System Program 11111111111111111111111111111111 (32 × 0x00) Native instructions (transfer, stake, NFT, ZK)
Contract Program 32 × 0xFF WASM contract calls (Deploy, Call, Upgrade, Close)

Economic Parameters

Parameter Value
Total supply 1,000,000,000 MOLT (fixed, not mintable)
Base fee 0.001 MOLT (1,000,000 shells)
Fee distribution 40% burn, 30% block producer, 10% voters, 10% treasury, 10% community
Contract deploy fee 25 MOLT
Contract upgrade fee 10 MOLT
NFT mint fee 0.5 MOLT
NFT collection fee 1,000 MOLT
Slots per day 216,000
Slots per year 78,840,000
Epoch length 432,000 slots (~2 days)

3. Native Transaction Types

All system instructions use program_id = System Program (all zeros). The first byte of data is the type tag.

Type Function Data Layout Accounts Description
0 system_transfer [0x00, amount:u64 LE] [from, to] Transfer MOLT. Blocked for governed wallets (use 21/22).
1 system_create_account [0x01] [pubkey] Create a new account. Fails if exists.
2-5 system_transfer (treasury) Same as 0 [treasury, recipient] Fee-free internal transfers. Treasury-only.
6 system_create_collection [0x06, json_data...] [creator, collection] Create NFT collection.
7 system_mint_nft [0x07, mint_data...] [minter, collection, token, owner] Mint NFT. Enforces supply cap.
8 system_transfer_nft [0x08] [owner, token, recipient] Transfer NFT ownership.
9 system_stake [0x09, amount:u64 LE] [staker, validator] Stake MOLT to validator.
10 system_request_unstake [0x0A, amount:u64 LE] [staker, validator] Request unstake (staked → locked).
11 system_claim_unstake [0x0B] [staker, validator] Claim after cooldown (locked → spendable).
12 system_register_evm_address [0x0C, evm_addr:20B] [native_pubkey] Map EVM address to native key. One-to-one.
13 system_reefstake_deposit [0x0D, amount:u64 LE, tier:u8?] [depositor] Liquid staking deposit. Mints stMOLT.
14 system_reefstake_unstake [0x0E, st_molt_amount:u64 LE] [user] Request stMOLT unstake. 7-day cooldown.
15 system_reefstake_claim [0x0F] [user] Claim unstaked MOLT after cooldown.
16 system_reefstake_transfer [0x10, st_molt_amount:u64 LE] [from, to] Transfer stMOLT between accounts.
17 system_deploy_contract [0x11, code_len:u32 LE, code..., init...] [deployer, treasury] Deploy WASM contract. Max 512KB.
18 system_set_contract_abi [0x12, abi_json...] [owner, contract_id] Set contract ABI. Owner-only.
19 system_faucet_airdrop [0x13, amount_shells:u64 LE] [treasury, recipient] Testnet faucet. Cap: 10 MOLT/request, 150 MOLT/day.
20 system_register_symbol [0x14, json...] [owner, contract_id] Register contract symbol in registry.
21 system_propose_governed_transfer [0x15, amount:u64 LE] [proposer, governed_wallet, recipient] Multi-sig transfer proposal.
22 system_approve_governed_transfer [0x16, proposal_id:u64 LE] [approver] Approve multi-sig. Auto-executes at threshold.
23 system_shield_deposit 169 bytes (see §10) [sender] ZK shield: transparent → shielded pool.
24 system_unshield_withdraw 233 bytes (see §10) [recipient] ZK unshield: shielded pool → transparent.
25 system_shielded_transfer 289 bytes (see §10) (none — fully private) ZK transfer: shielded → shielded.

4. Contract Call Format

WASM contracts are invoked via the Contract Program (program_id = [0xFF; 32]).

Instruction Data (JSON)

{
  "Call": {
    "function": "transfer",
    "args": [116, 111, ...],
    "value": 0
  }
}
  • function: The WASM export name to call
  • args: UTF-8 bytes of JSON-encoded arguments (e.g., Array.from(TextEncoder.encode(JSON.stringify({to: [...], amount: 1000}))))
  • value: Shells to transfer from caller to contract before execution (0 for read-only)

Other Contract Instructions

{ "Deploy": { "code": [...wasm_bytes], "init_data": [...] } }
{ "Upgrade": { "code": [...wasm_bytes] } }
{ "Close": null }

Account Layout for Contract Calls

  • accounts[0] = caller (signer, pays fees)
  • accounts[1] = contract address (target program)
  • Additional accounts optional

Two Dispatch Styles

Style Used By Mechanism
Named exports 23 standalone contracts Each function is a #[no_mangle] pub extern "C" fn name() WASM export
Opcode dispatch 7 DEX contracts Single call(args_ptr, args_len) export; first byte = opcode

5. Contract Surface (29 Contracts)

Token Contracts

moltcoin — Native MOLT token (SPL-like):
initialize, balance_of, transfer, mint, burn, approve, transfer_from, total_supply

musd_token — Stablecoin (mUSD) with reserve attestation:
initialize, mint, burn, transfer, approve, transfer_from, attest_reserves, balance_of, allowance, total_supply, total_minted, total_burned, get_reserve_ratio, get_last_attestation_slot, get_attestation_count, get_epoch_remaining, get_transfer_count, emergency_pause, emergency_unpause, transfer_admin

weth_token / wsol_token / wbnb_token — Wrapped assets with reserve attestation:
Same exports as musd_token.

DeFi Contracts

moltswap — AMM with flash loans and TWAP:
initialize, add_liquidity, remove_liquidity, swap_a_for_b, swap_b_for_a, swap_a_for_b_with_deadline, swap_b_for_a_with_deadline, get_quote, get_reserves, get_liquidity_balance, get_total_liquidity, flash_loan_borrow, flash_loan_repay, flash_loan_abort, get_flash_loan_fee, get_twap_cumulatives, get_twap_snapshot_count, set_protocol_fee, get_protocol_fees, set_identity_admin, set_moltyid_address, set_reputation_discount, ms_pause, ms_unpause, create_pool, swap, get_pool_info, get_pool_count, set_platform_fee, get_swap_count, get_total_volume, get_swap_stats

lobsterlend — Lending/borrowing with flash loans:
initialize, deposit, withdraw, borrow, repay, liquidate, get_account_info, get_protocol_stats, flash_borrow, flash_repay, pause, unpause, set_deposit_cap, set_reserve_factor, withdraw_reserves, set_moltcoin_address, get_interest_rate, get_deposit_count, get_borrow_count, get_liquidation_count, get_platform_stats

clawpay — Token streaming / vesting:
create_stream, withdraw_from_stream, cancel_stream, get_stream, get_withdrawable, create_stream_with_cliff, transfer_stream, initialize_cp_admin, set_token_address, set_self_address, pause, unpause, get_stream_info, set_identity_admin, set_moltyid_address, set_identity_gate, get_stream_count, get_platform_stats

clawpump — Token launchpad with bonding curves:
initialize, create_token, buy, sell, get_token_info, get_buy_quote, get_token_count, get_platform_stats, pause, unpause, freeze_token, unfreeze_token, set_buy_cooldown, set_sell_cooldown, set_max_buy, set_creator_royalty, withdraw_fees, set_molt_token, set_dex_addresses, get_graduation_info

clawvault — Yield vault with multi-strategy allocation:
initialize, add_strategy, deposit, withdraw, set_protocol_addresses, set_molt_token, harvest, get_vault_stats, get_user_position, get_strategy_info, cv_pause, cv_unpause, set_deposit_fee, set_withdrawal_fee, set_deposit_cap, set_risk_tier, remove_strategy, withdraw_protocol_fees, update_strategy_allocation

Bridge & Cross-Chain

moltbridge — Cross-chain bridge with multi-validator consensus:
initialize, add_bridge_validator, remove_bridge_validator, set_required_confirmations, set_request_timeout, lock_tokens, submit_mint, confirm_mint, submit_unlock, confirm_unlock, cancel_expired_request, get_bridge_status, has_confirmed_mint, has_confirmed_unlock, is_source_tx_used, is_burn_proof_used, set_moltyid_address, set_identity_gate, set_token_address, mb_pause, mb_unpause

Oracle

moltoracle — Price feeds, randomness, attestation:
initialize_oracle, add_price_feeder, set_authorized_attester, submit_price, get_price, commit_randomness, reveal_randomness, request_randomness, get_randomness, submit_attestation, verify_attestation, get_attestation_data, query_oracle, get_aggregated_price, get_oracle_stats, initialize, register_feed, get_feed_count, get_feed_list, add_reporter, remove_reporter, set_update_interval, mo_pause, mo_unpause

NFT & Marketplace

moltpunks — NFT collection (ERC-721 equivalent):
initialize, mint, transfer, owner_of, balance_of, approve, transfer_from, burn, total_minted, mint_punk, transfer_punk, get_owner_of, get_total_supply, get_punk_metadata, get_punks_by_owner, set_base_uri, set_max_supply, set_royalty, mp_pause, mp_unpause, get_collection_stats

moltmarket — NFT marketplace with offers, auctions, and collection offers:
initialize, list_nft, buy_nft, cancel_listing, get_listing, set_marketplace_fee, list_nft_with_royalty, make_offer, cancel_offer, accept_offer, get_marketplace_stats, set_nft_attributes, get_nft_attributes, get_offer_count, update_listing_price, create_auction, place_bid, settle_auction, cancel_auction, get_auction, make_collection_offer, accept_collection_offer, cancel_collection_offer, make_offer_with_expiry, mm_pause, mm_unpause

moltauction — NFT auction house:
create_auction, place_bid, finalize_auction, make_offer, accept_offer, set_royalty, update_collection_stats, get_collection_stats, initialize, set_reserve_price, cancel_auction, initialize_ma_admin, ma_pause, ma_unpause, get_auction_info, get_auction_stats

Governance

moltdao — On-chain governance with treasury:
initialize_dao, create_proposal, create_proposal_typed, vote, vote_with_reputation, execute_proposal, veto_proposal, cancel_proposal, treasury_transfer, get_treasury_balance, get_proposal, get_dao_stats, get_active_proposals, initialize, cast_vote, finalize_proposal, get_proposal_count, get_vote, get_vote_count, get_total_supply, set_quorum, set_voting_period, set_timelock_delay, dao_pause, dao_unpause, set_moltyid_address

Infrastructure

bountyboard — Decentralized bounty marketplace:
create_bounty, submit_work, approve_work, cancel_bounty, get_bounty, set_identity_admin, set_moltyid_address, set_identity_gate, set_token_address, initialize, approve_submission, get_bounty_count, set_platform_fee, bb_pause, bb_unpause, get_platform_stats

compute_market — Decentralized compute jobs:
register_provider, submit_job, claim_job, complete_job, dispute_job, get_job, initialize, set_claim_timeout, set_complete_timeout, set_challenge_period, add_arbitrator, remove_arbitrator, set_token_address, cancel_job, release_payment, resolve_dispute, deactivate_provider, reactivate_provider, update_provider, get_escrow, set_identity_admin, set_moltyid_address, set_identity_gate, create_job, accept_job, submit_result, confirm_result, get_job_info, get_job_count, get_provider_info, set_platform_fee, cm_pause, cm_unpause, get_platform_stats

reef_storage — Decentralized storage with staking and challenges:
store_data, confirm_storage, get_storage_info, register_provider, claim_storage_rewards, initialize, set_molt_token, set_challenge_window, set_slash_percent, stake_collateral, set_storage_price, get_storage_price, get_provider_stake, issue_challenge, respond_challenge, slash_provider, get_platform_stats

Privacy

shielded_pool — ZK shielded transaction pool (WASM contract):
initialize, shield, unshield, transfer, get_pool_stats, get_merkle_root, check_nullifier, get_commitments, pause, unpause

Note: Shield/unshield/transfer also operate as native instruction types 23/24/25 in the processor with full Groth16 proof verification. The WASM contract provides queryable on-chain state.

Prediction

prediction_market — Binary outcome prediction markets:
initialize, call (opcode-based dispatch)

Identity

moltyid — Full identity system (see §7 for complete reference):
59 exported functions covering identity, names, reputation, vouches, achievements, skills, attestations, agent profiles, delegation, recovery, trust, and admin.


6. DEX Contracts — Full Opcode Reference

All 7 DEX contracts use binary opcode dispatch via a single call(args_ptr, args_len) WASM export. First byte = opcode.

dex_core — Central Limit Order Book (31 opcodes)

Order types: Limit(0), Market(1), StopLimit(2), PostOnly(3). ReduceOnly flag: 0x80.
Fee defaults: maker −1bps rebate, taker 5bps. Distribution: 60% protocol / 20% LPs / 20% stakers.

Op Name Args
0x00 initialize [admin 32B]
0x01 create_pair [caller 32B][base 32B][quote 32B][tick_size 8B][lot_size 8B][min_order 8B]
0x02 place_order [trader 32B][pair_id 8B][side 1B][order_type 1B][price 8B][quantity 8B][trigger_price 8B]
0x03 cancel_order [trader 32B][order_id 8B]
0x04 set_preferred_quote [caller 32B][quote_addr 32B]
0x05 get_pair_count []
0x06 get_preferred_quote []
0x07 update_pair_fees [caller 32B][pair_id 8B][maker_fee 2B][taker_fee 2B]
0x08 emergency_pause [caller 32B]
0x09 emergency_unpause [caller 32B]
0x0A get_best_bid [pair_id 8B]
0x0B get_best_ask [pair_id 8B]
0x0C get_spread [pair_id 8B]
0x0D get_pair_info [pair_id 8B]
0x0E get_trade_count [pair_id 8B]
0x0F get_fee_treasury []
0x10 modify_order [trader 32B][order_id 8B][new_price 8B][new_quantity 8B]
0x11 cancel_all_orders [trader 32B][pair_id 8B]
0x12 pause_pair [caller 32B][pair_id 8B]
0x13 unpause_pair [caller 32B][pair_id 8B]
0x14 get_order [order_id 8B]
0x15 add_allowed_quote [caller 32B][quote_addr 32B]
0x16 remove_allowed_quote [caller 32B][quote_addr 32B]
0x17 get_allowed_quote_count []
0x18 execute_unpause [caller 32B][pair_id 8B]
0x19 get_total_volume [pair_id 8B]
0x1A get_user_orders [trader 32B][pair_id 8B]
0x1B get_open_order_count [pair_id 8B]
0x1C set_analytics_address [caller 32B][analytics_addr 32B]
0x1D check_triggers [pair_id 8B][current_price 8B]
0x1E set_margin_address [caller 32B][margin_addr 32B]

dex_amm — Concentrated Liquidity AMM (20 opcodes)

Uniswap V3-style with Q32.32 fixed-point sqrt prices. Fee tiers: 1bps (tick 1), 5bps (tick 10), 30bps (tick 60), 100bps (tick 200). MAX_TICK: ±443,636.

Op Name Args
0x00 initialize [admin 32B]
0x01 create_pool [caller 32B][tokenA 32B][tokenB 32B][fee_tier 1B][initial_sqrt_price 8B]
0x02 set_pool_protocol_fee [caller 32B][pool_id 8B][fee_bps 2B]
0x03 add_liquidity [provider 32B][pool_id 8B][lower_tick 4B][upper_tick 4B][amountA 8B][amountB 8B]
0x04 remove_liquidity [provider 32B][position_id 8B][amountA 8B][amountB 8B]
0x05 collect_fees [provider 32B][position_id 8B]
0x06 swap_exact_in [trader 32B][pool_id 8B][is_token_a_in 1B][amount_in 8B][min_out 8B][deadline 8B]
0x07 swap_exact_out [trader 32B][pool_id 8B][is_token_a_in 1B][amount_out 8B][max_in 8B][deadline 8B]
0x08 emergency_pause [caller 32B]
0x09 emergency_unpause [caller 32B]
0x0A get_pool_info [pool_id 8B]
0x0B get_position [position_id 8B]
0x0C get_pool_count []
0x0D get_position_count []
0x0E get_tvl [pool_id 8B]
0x0F quote_swap [pool_id 8B][is_token_a_in 1B][amount 8B]
0x10 get_total_volume []
0x11 get_swap_count []
0x12 get_total_fees_collected []
0x13 get_amm_stats []

dex_margin — Margin Trading (29 opcodes)

Leverage up to 100x with 7 tiered parameter sets. Funding: 8h intervals (28,800 slots).

Leverage Tiers:

Tier Max Leverage Init Margin Maint Margin Liquidation Fee
1 ≤2x 50% 25% 3%
2 ≤3x 33% 16% 4%
3 ≤5x 20% 10% 5%
4 ≤10x 10% 5% 7%
5 ≤25x 4% 2% 10%
6 ≤50x 2% 1% 12%
7 ≤100x 1% 0.5% 15%
Op Name Args
0x00 initialize [admin 32B]
0x01 set_mark_price [caller 32B][pair_id 8B][price 8B]
0x02 open_position [trader 32B][pair_id 8B][side 1B][size 8B][leverage 8B][margin 8B][margin_mode 1B?]
0x03 close_position [trader 32B][position_id 8B]
0x04 add_margin [trader 32B][position_id 8B][amount 8B]
0x05 remove_margin [trader 32B][position_id 8B][amount 8B]
0x06 liquidate [liquidator 32B][position_id 8B]
0x07 set_max_leverage [caller 32B][pair_id 8B][max_lev 8B]
0x08 set_maintenance_margin [caller 32B][pair_id 8B][margin 8B]
0x09 withdraw_insurance [caller 32B][amount 8B]
0x0A get_position_info [position_id 8B]
0x0B get_margin_ratio [position_id 8B]
0x0C get_tier_info [tier 1B]
0x0D emergency_pause [caller 32B]
0x0E emergency_unpause [caller 32B]
0x0F set_moltcoin_address [caller 32B][addr 32B]
0x10 get_total_volume []
0x11 get_user_positions [trader 32B]
0x12 get_total_pnl []
0x13 get_liquidation_count []
0x14 get_margin_stats []
0x15 enable_margin_pair [caller 32B][pair_id 8B]
0x16 disable_margin_pair [caller 32B][pair_id 8B]
0x17 is_margin_enabled [pair_id 8B]
0x18 set_position_sl_tp [caller 32B][position_id 8B][sl_price 8B][tp_price 8B]
0x19 partial_close [caller 32B][position_id 8B][close_amount 8B]
0x1A query_user_open_position [trader 32B][pair_id 8B]
0x1B close_position_limit [trader 32B][position_id 8B][limit_price 8B]
0x1C partial_close_limit [caller 32B][position_id 8B][close_amount 8B][limit_price 8B]

dex_router — Smart Order Routing (14 opcodes)

Route types: DIRECT_CLOB(0), DIRECT_AMM(1), SPLIT(2), MULTI_HOP(3), LEGACY_SWAP(4). Max hops: 4. Max split legs: 3. Max slippage: 500bps (5%).

Op Name Args
0x00 initialize [admin 32B]
0x01 set_addresses [caller 32B][core_addr 32B][amm_addr 32B][legacy_addr 32B]
0x02 register_route [caller 32B][tokenIn 32B][tokenOut 32B][type 1B][poolId 8B][secId 8B][splitPct 1B]
0x03 swap [trader 32B][tokenIn 32B][tokenOut 32B][amountIn 8B][minOut 8B][deadline 8B]
0x04 set_route_enabled [caller 32B][routeId 8B][enabled 1B]
0x05 get_best_route [tokenIn 32B][tokenOut 32B]
0x06 get_route_info [routeId 8B]
0x07 emergency_pause [caller 32B]
0x08 emergency_unpause [caller 32B]
0x09 multi_hop_swap [trader 32B][path Vec<32B>][pathCount 1B][amountIn 8B][minOut 8B][deadline 8B]
0x0A get_route_count []
0x0B get_swap_count []
0x0C get_total_volume_routed []
0x0D get_router_stats []

dex_governance — Governance (20 opcodes)

Voting: 48h (172,800 slots), 66% approval, MIN_QUORUM=3, 1h timelock. Min reputation: 500 (MoltyID). Min listing liquidity: 10,000 MOLT.

Op Name Args
0x00 initialize [admin 32B]
0x01 propose_new_pair [caller 32B][base 32B][quote 32B][tick_size 8B][lot_size 8B][min_order 8B]
0x02 vote [caller 32B][proposalId 8B][approve 1B]
0x03 finalize_proposal [caller 32B][proposalId 8B]
0x04 execute_proposal [caller 32B][proposalId 8B]
0x05 set_preferred_quote [caller 32B][quote_addr 32B]
0x06 get_preferred_quote []
0x07 get_proposal_count []
0x08 get_proposal_info [proposalId 8B]
0x09 propose_fee_change [caller 32B][pairId 8B][maker 2B][taker 2B]
0x0A emergency_delist [caller 32B][pairId 8B]
0x0B set_listing_requirements [caller 32B][min_liq 8B][min_rep 8B]
0x0C emergency_pause [caller 32B]
0x0D emergency_unpause [caller 32B]
0x0E set_moltyid_address [caller 32B][addr 32B]
0x0F add_allowed_quote [caller 32B][quote_addr 32B]
0x10 remove_allowed_quote [caller 32B][quote_addr 32B]
0x11 get_allowed_quote_count []
0x12 get_governance_stats []
0x13 get_voter_count []

dex_rewards — Trading Rewards (20 opcodes)

Fee mining, LP mining, referral program. Reward pool: 100K MOLT/month (1,200,000 MOLT total).

Trading Tiers:

Tier Volume Threshold Multiplier
Bronze < 100K 1.0×
Silver 100K – 1M 1.5×
Gold 1M – 10M 2.0×
Diamond > 10M 3.0×

Referral: 10% default (max 30%), 5% discount to referee, 15% for MoltyID-verified.

Op Name Args
0x00 initialize [admin 32B]
0x01 record_trade [trader 32B][fee 8B][volume 8B]
0x02 claim_trading_rewards [trader 32B]
0x03 claim_lp_rewards [provider 32B]
0x04 register_referral [trader 32B][referrer 32B]
0x05 set_reward_rate [caller 32B][rate 8B]
0x06 accrue_lp_rewards [provider 32B][amount 8B]
0x07 get_pending_rewards [trader 32B]
0x08 get_trading_tier [trader 32B]
0x09 emergency_pause [caller 32B]
0x0A emergency_unpause [caller 32B]
0x0B set_referral_rate [caller 32B][rate 8B]
0x0C set_moltcoin_address [caller 32B][addr 32B]
0x0D set_rewards_pool [caller 32B][pool_addr 32B]
0x0E get_referral_rate []
0x0F get_total_distributed []
0x10 get_trader_count []
0x11 get_total_volume []
0x12 get_reward_stats []
0x13 claim_referral_rewards [trader 32B]

dex_analytics — OHLCV Aggregation (13 opcodes)

9 candle intervals: 1m/5m/15m/1h/4h/1d/3d/1w/1y.

Interval Retention Max Candles
1m 24h 1,440
5m 7d 2,016
15m 30d 2,880
1h 90d 2,160
4h 365d 2,190
1d 3y 1,095
Op Name Args
0x00 initialize [admin 32B]
0x01 record_trade [pair_id 8B][price 8B][volume 8B][trader 32B]
0x02 get_ohlcv [pair_id 8B][interval 8B][count 8B]
0x03 get_24h_stats [pair_id 8B]
0x04 get_trader_stats [trader 32B]
0x05 get_last_price [pair_id 8B]
0x06 get_record_count []
0x07 emergency_pause [caller 32B]
0x08 emergency_unpause [caller 32B]
0x09 get_trader_count []
0x0A get_global_stats []
0x0B set_authorized_caller [caller 32B][auth_addr 32B]
0x0C record_pnl [trader 32B][pnl_biased 8B]

7. MoltyID Identity System

MoltyID is the decentralized identity layer. 51 WASM exports covering identity, naming, reputation, vouches, achievements, skills, attestations, agent profiles, delegation, and social recovery.

Identity Registration

  1. Call register_identity(owner_ptr, agent_type, name_ptr, name_len)
  2. Validates: not paused, name 1-64 bytes, valid agent type, no duplicate
  3. Initial reputation: 100, cooldown: 60s between registrations
  4. Record: 127 bytes — [owner(32), agent_type(1), name_len(2), name(64), reputation(8), created_at(8), updated_at(8), skill_count(1), vouch_count(2)+flags(1), is_active(1)]

Agent Types

ID Type
0 Unknown
1 Trading
2 Development
3 Analysis
4 Creative
5 Infrastructure
6 Governance
7 Oracle
8 Storage
9 General
10 Personal

.MOLT Name System

Name Length Cost Mechanism
3 chars 500 MOLT Auction-only
4 chars 100 MOLT Auction-only
5+ chars 20 MOLT Direct registration
  • Duration: 1-10 years, cost = base × years
  • Expiry: current_slot + (78,840,000 × years)
  • Validation: 3-32 chars, lowercase a-z, 0-9, hyphens; no leading/trailing/consecutive hyphens
  • One name per identity
  • ~35 reserved names (moltchain, treasury, dex, admin, system, etc.)
  • Premium auctions: 1-14 days (216,000–3,024,000 slots)

Reputation System

Parameter Value
Initial score 100
Minimum 0
Maximum 100,000
Decay period 90 days
Decay rate 5% per period

Contribution types:

Type Action Delta
0 successful_tx +10
1 governance_participation +50
2 program_deployed +100
3 uptime_hour +1
4 peer_endorsement +25
5 failed_tx −5
6 slashing_event −100

Vouch System

Parameter Value
Voucher cost −5 rep (voucher pays)
Vouchee reward +10 rep (vouchee gains)
Max vouches/identity 64
Cooldown 1 hour
Self-vouch Forbidden
Duplicate vouch Forbidden

Skills & Attestations

  • Max 16 skills, max 32-byte name, proficiency 0-100
  • +10 rep per skill added
  • Third-party attestations: level 1-5
  • Cannot self-attest; both parties need MoltyID

Delegation System

Owner grants bitfield permissions to delegates with TTL (max 1 year):

  • 0b0001 — PROFILE (endpoint, metadata, availability, rate)
  • 0b0010 — AGENT_TYPE
  • 0b0100 — SKILLS
  • 0b1000 — NAMING (transfer, renew, release names)

Recovery Guardians

  • 5 guardians, 3-of-5 threshold
  • Each guardian must have previously vouched for the target
  • Flow: set_recovery_guardians → 3× approve_recoveryexecute_recovery
  • Old identity deactivated, new owner inherits everything

Complete MoltyID Exports (59 functions)

Identity: initialize, register_identity, get_identity, deactivate_identity, get_identity_count
Reputation: update_reputation, update_reputation_typed, get_reputation
Agent type: update_agent_type, update_agent_type_as
Vouches: vouch, get_vouches
Achievements: award_contribution_achievement, get_achievements
Skills: add_skill, add_skill_as, get_skills, attest_skill, get_attestations, revoke_attestation
Names: register_name, resolve_name, reverse_resolve, create_name_auction, bid_name_auction, finalize_name_auction, get_name_auction, transfer_name, renew_name, release_name, transfer_name_as, renew_name_as, release_name_as, admin_register_reserved_name
Agent profile: set_endpoint, get_endpoint, set_metadata, get_metadata, set_availability, get_availability, set_rate, get_rate, get_agent_profile
Trust: get_trust_tier
Delegation: set_delegate, revoke_delegate, get_delegate, set_endpoint_as, set_metadata_as, set_availability_as, set_rate_as
Recovery: set_recovery_guardians, approve_recovery, execute_recovery
Admin: mid_pause, mid_unpause, transfer_admin, set_mid_token_address, set_mid_self_address

8. Achievement System (90+ Achievements)

Achievements are auto-detected by detect_and_award_achievements() in the processor after every successful transaction. They require the sender to have a MoltyID identity.

General

ID Name Trigger
1 First Transaction Any successful tx
106 Big Spender Transfer ≥100 MOLT
107 Whale Transfer Transfer ≥1,000 MOLT
124 Contract Interactor Any contract call

DEX

ID Name Trigger
13 First Trade Any swap on DEX/MOLTSWAP
14 LP Provider Add liquidity
15 LP Withdrawal Remove liquidity
16 DEX User Any DEX interaction
17 Multi-hop Trader Use DEX_ROUTER
18 Margin Trader Open margin position
19 Position Closer Close margin position
20 Yield Farmer Claim DEX rewards
21 Analytics Explorer Use DEX_ANALYTICS

Lending

ID Name Trigger
31 First Lend Deposit to LOBSTERLEND
32 First Borrow Borrow from LOBSTERLEND
33 Loan Repaid Repay loan
34 Liquidator Liquidate position
35 Withdrawal Expert Withdraw from LOBSTERLEND

Stablecoin

ID Name Trigger
36 Stablecoin Minter Mint mUSD
37 Stablecoin Redeemer Burn mUSD
38 Stable Sender Transfer mUSD

Staking

ID Name Trigger
41 First Stake System stake
42 Unstaked System unstake
43 ReefStake Pioneer First ReefStake deposit
44 Locked Staker Deposit with tier ≥1
45 Diamond Hands 365-day lock tier
46 Whale Staker Deposit ≥10,000 MOLT
47 Reward Harvester Claim ReefStake rewards
48 stMOLT Transferrer Transfer stMOLT

Bridge & Cross-Chain

ID Name Trigger
51 Bridge Pioneer (In) MOLTBRIDGE deposit/lock
52 Bridge Out MOLTBRIDGE withdraw/claim
53 Bridge User Any MOLTBRIDGE call
54 Wrapper Wrap WETH/WBNB/WSOL
55 Unwrapper Unwrap WETH/WBNB/WSOL
56 Cross-chain Trader Transfer wrapped asset
108 EVM Connected Register EVM address

Privacy (ZK)

ID Name Trigger
57 Privacy Pioneer First shield deposit
58 Unshielded First unshield
59 Shadow Sender First shielded transfer
60 ZK Privacy User Interact with SHIELDED_POOL

NFT & Marketplace

ID Name Trigger
63 Collection Creator Create NFT collection
64 First Mint Mint NFT
65 NFT Trader Transfer NFT
66 First Listing List on MOLTMARKET
67 First Purchase Buy on MOLTMARKET
68 Bidder Bid on MOLTMARKET
69 Deal Maker Accept offer on MOLTMARKET
70 Punk Collector Interact with MOLTPUNKS

Governance

ID Name Trigger
2 Governance Voter Any DEX_GOVERNANCE/MOLTDAO vote
3 Program Builder Deploy a contract
71 Proposal Creator Create proposal
72 First Vote Cast first vote
73 Delegator Delegate votes

Oracle & Storage

ID Name Trigger
81 Oracle Reporter Submit price to MOLTORACLE
82 Oracle User Any MOLTORACLE call
86 File Uploader Upload to REEF_STORAGE
87 Data Retriever Download from REEF_STORAGE
88 Storage User Any REEF_STORAGE call

Auction & Bounty

ID Name Trigger
91 Auctioneer Create MOLTAUCTION
92 Auction Bidder Bid on MOLTAUCTION
93 Auction Winner Claim/settle MOLTAUCTION
96 Bounty Poster Post on BOUNTYBOARD
97 Bounty Hunter Submit work on BOUNTYBOARD
98 Bounty Judge Approve submission

Prediction Markets

ID Name Trigger
101 Market Maker Create prediction market
102 First Prediction Place prediction bet
103 Oracle Resolver Resolve market
104 Prediction Winner Claim winnings

Payments & Tokens

ID Name Trigger
115 Payment Creator Create ClawPay stream
116 First Payment Send ClawPay payment
117 Subscription Creator Create ClawPay subscription
118 Token Launcher Launch token on ClawPump
119 Early Buyer Buy on ClawPump
120 Token Seller Sell on ClawPump
121 Vault Depositor Deposit to ClawVault
122 Vault Withdrawer Withdraw from ClawVault
123 Token Contract User Interact with MOLTCOIN

Compute & Identity

ID Name Trigger
113 Compute Provider Register as compute provider
114 Compute Consumer Submit compute job
109 Identity Created Register MoltyID identity
110 Profile Customizer Update profile
111 Voucher Give a vouch
112 Agent Creator Create agent
9 Name Registrar Register .molt name
12 First Name Register first .molt name

Contract-Awarded (Reputation Milestones)

ID Name Trigger
4 Trusted Agent Rep ≥500
5 Veteran Agent Rep ≥1,000
6 Legendary Agent Rep ≥5,000
7 Well Endorsed ≥10 vouches received
10 Skill Master ≥5 skills
11 Social Butterfly ≥3 vouches received

9. Staking & ReefStake

Basic Validator Staking

Operation Type Data Accounts
Stake 9 [0x09, amount:u64 LE] [staker, validator]
Request unstake 10 [0x0A, amount:u64 LE] [staker, validator]
Claim unstake 11 [0x0B] [staker, validator]

ReefStake — Liquid Staking

Operation Type Data Accounts
Deposit 13 [0x0D, amount:u64 LE, tier:u8?] [depositor]
Unstake 14 [0x0E, st_molt_amount:u64 LE] [user]
Claim 15 [0x0F] [user]
Transfer stMOLT 16 [0x10, st_molt_amount:u64 LE] [from, to]

Lock Tiers

Tier Byte Lock Duration APY Multiplier Target APY
Flexible 0 None (7-day unstake cooldown) 1.0× ~5%
30-Day 1 6,480,000 slots 1.6× ~8%
180-Day 2 38,880,000 slots 2.4× ~12%
365-Day 3 78,840,000 slots 3.6× ~18%

stMOLT Mechanics

  • Exchange rate: fixed-point with 1e9 precision, starts at 1.0
  • Minting: st_molt = (molt × PRECISION) / exchange_rate
  • Redemption: molt = (st_molt × exchange_rate) / PRECISION
  • Auto-compound: distribute_rewards() increases exchange rate
  • Block reward share: 10% of block rewards → ReefStake pool
  • Tier change: must withdraw and re-stake (no in-place change)

10. ZK Shielded Transactions

Architecture

  • Proof system: Groth16 over BN254 (arkworks)
  • Hash: Poseidon (SNARK-friendly)
  • Commitments: Pedersen over BN254 G1
  • Merkle tree depth: 20 (supports ~1M commitments)
  • Note encryption: ChaCha20-Poly1305

Boot-Time Setup

Canonical Groth16 ceremony keys are committed to zk-keys/ in the repo and shipped in every release tarball (inside zk/). On first boot, the validator copies bundled keys from the zk/ directory next to the executable into ~/.moltchain/zk/:

  • vk_shield.bin, pk_shield.bin
  • vk_unshield.bin, pk_unshield.bin
  • vk_transfer.bin, pk_transfer.bin

All validators must use the same verification keys for cross-verifiable shielded proofs. Keys are never generated at runtime — if missing, the validator logs a warning and disables shielded transactions but still starts. To regenerate manually: zk-setup --output ~/.moltchain/zk/.

Compute Costs

Operation Compute Units
Shield 100,000
Unshield 150,000
Transfer 200,000

Type 23 — Shield Deposit (transparent → shielded)

Data (169 bytes):
  [0]       = 0x17 (23)
  [1..9]    = amount (u64 LE, shells)
  [9..41]   = commitment (32B, Poseidon hash of value‖blinding)
  [41..169] = Groth16 proof (128B, compressed BN254)

Public inputs: [amount_fr, commitment_fr]
Accounts: [sender]

Debits sender balance. Inserts commitment into Merkle tree. Increments total_shielded.

Type 24 — Unshield Withdraw (shielded → transparent)

Data (233 bytes):
  [0]        = 0x18 (24)
  [1..9]     = amount (u64 LE, shells)
  [9..41]    = nullifier (32B)
  [41..73]   = merkle_root (32B)
  [73..105]  = recipient_fr (32B, Poseidon(Fr(pubkey), 0))
  [105..233] = Groth16 proof (128B)

Public inputs: [merkle_root, nullifier, amount, recipient]
Accounts: [recipient]

Verifies root matches, nullifier unspent, recipient bound. Credits recipient. Marks nullifier spent.

Type 25 — Shielded Transfer (shielded → shielded)

Data (289 bytes):
  [0]         = 0x19 (25)
  [1..33]     = nullifier_a (32B)
  [33..65]    = nullifier_b (32B)
  [65..97]    = commitment_c (32B, output 0)
  [97..129]   = commitment_d (32B, output 1)
  [129..161]  = merkle_root (32B)
  [161..289]  = Groth16 proof (128B)

Public inputs: [merkle_root, nullifier_a, nullifier_b, commitment_c, commitment_d]
Accounts: (none — fully private)

2-in-2-out private transfer. Spends two notes, creates two new commitments. Value conservation enforced by ZK circuit.

Wallet-Side Key Derivation

spending_key = SHA-256(seed ‖ "moltchain-shielded-spending-key-v1")
viewing_key  = SHA-256(spending_key ‖ "moltchain-viewing-key-v1")

Note decryption: XOR cipher with viewing key, 104-byte notes.


11. RPC Methods

Native MoltChain JSON-RPC (POST /)

Core Blockchain

Method Params Returns
getBalance [pubkey] {balance, spendable, staked, shells, molt}
getAccount [pubkey] {address, balance, owner, executable, nonce}
getBlock [slot] {slot, hash, parent_hash, transactions}
getLatestBlock none Latest block JSON
getSlot [{commitment?}] Current slot (u64)
getTransaction [hash_hex] {hash, status, slot, from, to, amount}
getTransactionsByAddress [pubkey, {limit?, before_slot?}] Array of tx summaries
getAccountTxCount [pubkey] {count}
getRecentTransactions [{limit?}] Array of recent txs
getTokenAccounts [pubkey] Token accounts for owner
sendTransaction [base64_tx] {signature}
confirmTransaction [hash_hex] {confirmed, slot, status}
simulateTransaction [base64_tx] {success, logs, error?}
getTotalBurned none {total_burned_shells}
getRecentBlockhash none {blockhash, slot}
health none {"status": "ok"}

Validators & Network

Method Params Returns
getValidators none Validator array (pubkey, stake, blocks)
getValidatorInfo [pubkey] Single validator detail
getValidatorPerformance [pubkey] Performance metrics
getChainStatus none {slot, epoch, validators, tps}
getMetrics none Full chain metrics
getTreasuryInfo none Treasury balances
getPeers none Connected peers
getNetworkInfo none {peer_count, node_version, chain_id}
getClusterInfo none Cluster topology

Staking

Method Params Returns
stake [pubkey, amount] {success, staked}
unstake [pubkey, amount] {success, unstaked}
getStakingStatus [pubkey] {staked, rewards, validator}
getStakingRewards [pubkey] Reward history and unclaimed
getStakingPosition [user_pubkey] {st_molt_amount, current_value, lock_tier}
getReefStakePoolInfo none {total_supply_st_molt, exchange_rate, apy, tiers}
getUnstakingQueue [user_pubkey] {pending_requests[], total_claimable}
getRewardAdjustmentInfo none {decay, APY, fee_split}

Configuration (Admin)

Method Params Returns
getFeeConfig none {base_fee_shells, contract_deploy_fee_shells, nft_mint_fee_shells, fee_burn_percent, ...}
setFeeConfig {base_fee_shells?, ...} (admin-gated, percentages must sum to 100) {status: "ok"}
getRentParams none {rent_rate_shells_per_kb_month, rent_free_kb}
setRentParams {rent_rate_shells_per_kb_month?, rent_free_kb?} (admin-gated) {status: "ok"}

Contracts

Method Params Returns
callContract {contract, function, args?} or [contract_base58, function_name, args_base64?] {success, returnData, returnCode, logs, error, computeUsed}
deployContract [deployer_base58, code_base64, init_data_json, signature_hex] (admin-gated) {program_id, deployer, code_size, deploy_fee, deploy_fee_molt}
upgradeContract [owner_base58, contract_base58, code_base64, signature_hex] (admin-gated) {program_id, owner, version, previous_version, code_size, upgrade_fee}
getContractInfo [program_id] {symbol, owner, version, abi}
getContractLogs [program_id, {limit?}] Contract logs
getContractAbi [program_id] ABI JSON
getAllContracts none All deployed contracts
getProgram [program_id] Program metadata
getProgramStats [program_id] {call_count, storage_size}
getPrograms [{limit?, offset?}] Paginated list
getProgramCalls [program_id, {limit?}] Recent calls
getProgramStorage [program_id, key] Raw storage value

MoltyID (Identity)

Method Params Returns
getMoltyIdIdentity [pubkey] {name, avatar, bio, verified}
getMoltyIdReputation [pubkey] {score, level}
getMoltyIdSkills [pubkey] {skills: []}
getMoltyIdVouches [pubkey] {vouches: []}
getMoltyIdAchievements [pubkey] {achievements: []}
getMoltyIdProfile [pubkey] Full composite profile
resolveMoltName [name] {pubkey}
reverseMoltName [pubkey] {name}
batchReverseMoltNames [pubkey_array] {names: {pubkey: name}}
searchMoltNames [query, {limit?}] Matching names
getMoltyIdAgentDirectory [{limit?, offset?}] Agent directory
getMoltyIdStats none {total_identities, total_vouches}
getNameAuction [name] Auction state

NFT & Marketplace

Method Params Returns
getCollection [id] Collection metadata
getNFT [collection_id, token_id] NFT metadata, owner
getNFTsByOwner [owner, {limit?}] Array of NFTs
getNFTsByCollection [collection_id, {limit?}] NFTs in collection
getNFTActivity [collection_id, {limit?}] Activity history
getMarketListings [{limit?}] Active listings
getMarketSales [{limit?}] Recent sales

Tokens

Method Params Returns
getTokenBalance [token_program, holder] {balance, decimals, symbol}
getTokenHolders [token_program, limit?] {holders: [{holder, balance}]}
getTokenTransfers [token_program, limit?] {transfers: [{from, to, amount}]}
getContractEvents [program_id, limit?] {events: [{name, data, slot}]}

Shielded Pool

Method Params Returns
getShieldedPoolState none {merkle_root, commitment_count, total_shielded, vk_hashes}
getShieldedPoolStats none Alias of getShieldedPoolState
getShieldedMerkleRoot none {merkle_root, commitment_count}
getShieldedMerklePath [index] {siblings, path_bits, root}
isNullifierSpent [hex_hash] {nullifier, spent: bool}
checkNullifier [hex_hash] Alias of isNullifierSpent
getShieldedCommitments [{from?, limit?}] Paginated commitments (max 1000)
computeShieldCommitment [{amount, blinding}] {amount, blinding, commitment}
generateShieldProof [{amount, blinding}] {type:"shield", amount, blinding, commitment, proof}
generateUnshieldProof [{amount, merkle_root, recipient, blinding, serial, spending_key, merkle_path?, path_bits?}] {type:"unshield", nullifier, recipient_hash, proof}
generateTransferProof [{merkle_root, inputs:[{amount, blinding, serial, spending_key, merkle_path, path_bits} ×2], outputs:[{amount, blinding} ×2]}] {type:"transfer", nullifiers[], output_commitments[], proof}

Platform Stats (per-contract)

Method Returns
getDexCoreStats pair_count, order_count, trade_count, total_volume
getDexAmmStats pool_count, position_count, swap_count
getDexMarginStats position_count, total_volume, liquidation_count
getDexRewardsStats trade_count, total_distributed
getDexRouterStats route_count, swap_count, total_volume
getDexAnalyticsStats record_count, total_candles
getDexGovernanceStats proposal_count, total_votes
getMoltswapStats swap_count, volume_a, volume_b
getLobsterLendStats deposits, borrows, reserves
getClawPayStats stream_count, total_streamed
getBountyBoardStats bounty_count, reward_volume
getComputeMarketStats job_count, payment_volume
getReefStorageStats data_count, total_bytes
getMoltMarketStats listing_count, sale_volume
getMoltAuctionStats auction_count, total_volume
getMoltPunksStats total_minted, transfer_count
getMusdStats / getWethStats / getWsolStats supply, minted, burned
getClawVaultStats total_assets, strategy_count
getMoltBridgeStats validator_count, locked_amount
getMoltDaoStats proposal_count
getMoltOracleStats queries, feeds

Prediction Markets

Method Params Returns
getPredictionMarketStats none {total_markets, open_markets, volume}
getPredictionMarkets [{category?, status?, limit?}] Paginated list
getPredictionMarket [market_id] Market + outcomes
getPredictionPositions [address] User positions
getPredictionTraderStats [address] {volume, trade_count}
getPredictionLeaderboard [{limit?}] Top traders
getPredictionTrending none Top 10 markets by 24h vol

EVM & Symbol Registry

Method Params
getEvmRegistration [pubkey]
lookupEvmAddress [evm_addr]
getSymbolRegistry [symbol]
getAllSymbolRegistry [{limit?, offset?}]

Bridge Deposits (Custody Proxy)

Method Params Returns
createBridgeDeposit [{user_id, chain, asset}] (chains: solana/ethereum/bnb/bsc; assets: sol/eth/bnb/usdc/usdt) Deposit object (address, status)
getBridgeDeposit [deposit_id] (UUID) Deposit object
getBridgeDepositsByRecipient [address, {limit?}] (max 100) Deposits array

Solana-Compatible JSON-RPC (POST /solana)

Method Description
getLatestBlockhash {blockhash, lastValidBlockHeight}
getRecentBlockhash Alias of getLatestBlockhash
getBalance Lamports-style balance
getAccountInfo Solana-format account
getBlock Solana-format block
getBlockHeight Block height
getSignaturesForAddress Signature records
getSignatureStatuses Status per signature
getSlot Current slot
getTransaction Solana-format tx
sendTransaction Submit base64 tx
getHealth "ok"
getVersion {"solana-core": "moltchain"}

Ethereum-Compatible JSON-RPC (POST /evm)

Method Description
eth_getBalance Hex balance in wei
eth_sendRawTransaction Submit hex tx
eth_call Simulate call
eth_chainId Hex chain ID
eth_blockNumber Hex block number
eth_getTransactionReceipt Receipt
eth_getTransactionByHash Tx details
eth_accounts Returns [] (no server-side accounts)
eth_gasPrice "0x1" (1 shell/gas)
eth_maxPriorityFeePerGas Returns "0x0"
eth_estimateGas Gas estimate
eth_getCode Bytecode
eth_getTransactionCount Nonce
eth_getBlockByNumber / eth_getBlockByHash Block
eth_getLogs Event logs (Keccak-256 topics)
eth_getStorageAt Storage slot
net_version / net_listening Network info
web3_clientVersion "MoltChain/{version}"

12. REST API Endpoints

DEX (/api/v1/*)

Method Path Description
GET /api/v1/pairs All trading pairs
GET /api/v1/pairs/:id Single pair
GET /api/v1/pairs/:id/orderbook Order book (bids/asks)
GET /api/v1/pairs/:id/trades Recent trades
GET /api/v1/pairs/:id/candles OHLCV candles
GET /api/v1/pairs/:id/stats 24h stats
GET /api/v1/pairs/:id/ticker Current ticker
GET /api/v1/tickers All tickers
GET /api/v1/orders?trader=&pair_id= Orders
POST /api/v1/orders Place order (builds tx)
GET /api/v1/orders/:id Single order
DELETE /api/v1/orders/:id Cancel order (builds tx)
GET /api/v1/pools AMM pools
GET /api/v1/pools/:id Pool detail
GET /api/v1/pools/positions?owner= LP positions
GET /api/v1/margin/positions?trader= Margin positions
GET /api/v1/margin/positions/:id Single position
POST /api/v1/margin/open Open margin position (builds tx)
POST /api/v1/margin/close Close margin position (builds tx)
GET /api/v1/margin/info Margin params
GET /api/v1/margin/enabled-pairs Margin-enabled pairs
GET /api/v1/margin/funding-rate Funding rates
POST /api/v1/router/swap Execute swap (builds tx)
POST /api/v1/router/quote Quote best route
GET /api/v1/routes All configured routes
GET /api/v1/leaderboard Top traders
GET /api/v1/traders/:addr/stats Trader stats
GET /api/v1/rewards/:addr Claimable rewards
GET /api/v1/governance/proposals Governance proposals
POST /api/v1/governance/proposals Create governance proposal (builds tx)
GET /api/v1/governance/proposals/:id Single proposal detail
POST /api/v1/governance/proposals/:id/vote Vote on proposal (builds tx)
GET /api/v1/stats/core CLOB stats
GET /api/v1/stats/amm AMM stats
GET /api/v1/stats/margin Margin stats
GET /api/v1/stats/router Router stats
GET /api/v1/stats/rewards Reward stats
GET /api/v1/stats/analytics Analytics stats
GET /api/v1/stats/governance Governance stats
GET /api/v1/stats/moltswap Moltswap stats
GET /api/v1/oracle/prices Oracle price feeds

Prediction Market (/api/v1/prediction-market/*)

Method Path Description
GET /api/v1/prediction-market/config Platform configuration
GET /api/v1/prediction-market/stats Market stats
GET /api/v1/prediction-market/markets Paginated markets
GET /api/v1/prediction-market/markets/:id Single market
GET /api/v1/prediction-market/markets/:id/price-history Price history
GET /api/v1/prediction-market/markets/:id/analytics Market analytics
GET /api/v1/prediction-market/positions?address= User positions
GET /api/v1/prediction-market/trades Recent trades
GET /api/v1/prediction-market/traders/:addr/stats Trader stats
GET /api/v1/prediction-market/leaderboard Top traders
GET /api/v1/prediction-market/trending Top 10 active
POST /api/v1/prediction-market/trade Execute trade (builds tx)
POST /api/v1/prediction-market/create Create market (builds tx)
POST /api/v1/prediction-market/create-template Create from template (builds tx)

Launchpad (/api/v1/launchpad/*)

Method Path Description
GET /api/v1/launchpad/config Platform configuration
GET /api/v1/launchpad/stats Platform stats
GET /api/v1/launchpad/tokens Token list
GET /api/v1/launchpad/tokens/:id Token detail
GET /api/v1/launchpad/tokens/:id/quote?amount= Buy quote
GET /api/v1/launchpad/tokens/:id/holders Holder lookup

Shielded Pool (/api/v1/shielded/*)

Method Path Description
GET /api/v1/shielded/pool Pool state
GET /api/v1/shielded/merkle-root Merkle root
GET /api/v1/shielded/merkle-path/:index Merkle proof
GET /api/v1/shielded/nullifier/:hash Nullifier check
GET /api/v1/shielded/commitments Commitment list
POST /api/v1/shielded/shield Submit shield tx
POST /api/v1/shielded/unshield Submit unshield tx
POST /api/v1/shielded/transfer Submit private transfer tx

13. WebSocket Subscriptions

Connect to ws://localhost:8900 (local) or wss://ws.moltchain.network (production). Send JSON-RPC subscribe messages.

Core

Subscribe Unsubscribe Params Events
subscribeSlots / slotSubscribe unsubscribeSlots none Slot notifications
subscribeBlocks unsubscribeBlocks none Block notifications
subscribeTransactions unsubscribeTransactions none Tx notifications
subscribeAccount unsubscribeAccount {pubkey} Balance changes
subscribeLogs unsubscribeLogs {program_id?} Contract logs
subscribeSignatureStatus unsubscribeSignatureStatus {signature_hex} Tx confirmation
subscribeEpochs unsubscribeEpochs none Epoch boundaries

Programs

Subscribe Params Events
subscribeProgramUpdates none Deploy/upgrade events
subscribeProgramCalls {program_id?} Invocation events

NFT & Marketplace

Subscribe Params Events
subscribeNftMints {collection_id?} Mint events
subscribeNftTransfers {collection_id?} Transfer events
subscribeMarketListings none New listings
subscribeMarketSales none Sale events

Bridge

Subscribe Events
subscribeBridgeLocks Lock events
subscribeBridgeMints Mint events

DEX

Subscribe Params
subscribeDex {channel: "orderbook:<pair_id>"}
subscribeDex {channel: "trades:<pair_id>"}
subscribeDex {channel: "ticker:<pair_id>"}
subscribeDex {channel: "candles:<pair_id>:<interval>"}
subscribeDex {channel: "orders:<trader_addr>"}
subscribeDex {channel: "positions:<trader_addr>"}

Prediction Markets

Subscribe Params
subscribePrediction {channel: "all"} or {channel: "market:<id>"}

Validators, Tokens, Governance

Subscribe Params Events
subscribeValidators none Validator set changes
subscribeTokenBalance {owner, mint?} Token balance changes
subscribeGovernance none Governance events

14. JavaScript SDK

Package: @moltchain/sdk in sdk/js/src/

Key Classes

import { PublicKey, Keypair, Connection, TransactionBuilder } from '@moltchain/sdk';

// Create wallet
const kp = Keypair.generate();
const pub = kp.pubkey();  // PublicKey

// Connect
// Local:   new Connection('http://localhost:8899', 'ws://localhost:8900');
// Production:
const conn = new Connection('https://rpc.moltchain.network', 'wss://ws.moltchain.network');

// Query
const balance = await conn.getBalance(pub.toBase58());
const slot = await conn.getSlot();

// Transfer
const tx = TransactionBuilder.transfer(kp.pubkey(), toPub, 1_000_000_000);
tx.setRecentBlockhash(await conn.getRecentBlockhash());
const signed = tx.buildAndSign(kp);
const sig = await conn.sendTransaction(btoa(JSON.stringify(signed)));

// Contract call
const callTx = new TransactionBuilder();
callTx.add({
  programId: Array.from(new Uint8Array(32).fill(0xFF)),  // Contract Program
  accounts: [Array.from(kp.pubkey().toBytes()), Array.from(contractPub.toBytes())],
  data: Array.from(new TextEncoder().encode(JSON.stringify({
    Call: { function: "transfer", args: Array.from(new TextEncoder().encode(
      JSON.stringify({ to: [...recipientBytes], amount: 1000 })
    )), value: 0 }
  })))
});

// WebSocket subscriptions
conn.onSlot((slot) => console.log('New slot:', slot));
conn.onBlock((block) => console.log('New block:', block));
conn.onAccountChange(address, (account) => console.log('Changed:', account));

Wire Format (Bincode)

Transaction: [u64 sig_count][sig₁ 64B]...[u64 ix_count][ix₁]...[blockhash 32B]
Instruction: [programId 32B][u64 acct_count][acct₁ 32B]...[u64 data_len][data...]

15. Wallet Operations

Key Generation

  1. BIP39 12-word mnemonic (128-bit entropy)
  2. PBKDF2-HMAC-SHA512 (mnemonic, "mnemonic" + passphrase, 2048 iterations)
  3. First 32 bytes → Ed25519 seed → keypair
  4. Private key encrypted with AES-256-GCM via Web Crypto API

Transaction Building Flow

1. latestBlock = await rpc.getLatestBlock()
2. Build instruction data: Uint8Array with [opcode, ...args]
3. message = { instructions: [{program_id, accounts, data}], blockhash }
4. privateKey = MoltCrypto.decryptPrivateKey(encryptedKey, password)
5. messageBytes = serializeMessageBincode(message)
6. signature = MoltCrypto.signTransaction(privateKey, messageBytes)
7. tx = { signatures: [signature], message }
8. base64 = btoa(JSON.stringify(tx))
9. rpc.sendTransaction(base64)

Token Transfers (mUSD, wSOL, wETH, wBNB)

program_id = [0xFF × 32]  // CONTRACT_PROGRAM_ID
accounts   = [from_pubkey, token_contract_pubkey]
data       = JSON.stringify({
  Call: {
    function: "transfer",
    args: TextEncoder.encode(JSON.stringify({ to: [...toPubkey], amount: rawAmount })),
    value: 0
  }
})

EVM Address Registration

Auto-derives 20-byte address via Keccak256(pubkey)[12:32] and sends type 12 tx on wallet creation/login. Cached in localStorage.

Bridge Deposits (via Custody)

  1. POST /deposits → deposit address
  2. Poll GET /deposits/:id every 5s
  3. Status: issued → pending → confirmed → swept → credited
  4. Supported: Solana (SOL, USDC, USDT), Ethereum (ETH, USDC, USDT), BSC (BNB)

16. CLI Reference

Binary: molt. Global: --rpc-url (default http://localhost:8899).

Core Commands

molt balance [address]                       # Check balance
molt transfer <to> <amount>                  # Transfer MOLT
molt deploy <contract.wasm>                  # Deploy WASM contract
                                                 # flags: --symbol, --name, --template,
                                                 #   --decimals, --supply, --metadata (JSON)
molt upgrade <address> <contract.wasm>       # Upgrade contract
molt call <contract> <function> --args '[...]'  # Call contract function
molt block <slot>                            # Get block info
molt latest                                  # Get latest block
molt slot                                    # Current slot
molt blockhash                               # Recent blockhash
molt burned                                  # Total burned MOLT
molt validators                              # List validators
molt status                                  # Chain status
molt metrics                                 # Performance metrics

Wallet Management

molt wallet create [name]                    # Create wallet
molt wallet import <name> --keypair <path>   # Import wallet
molt wallet list                             # List wallets
molt wallet show <name>                      # Show details
molt wallet balance <name>                   # Get balance
molt wallet remove <name>                    # Remove wallet

Identity & Keypair

molt identity new --output <path>            # Create identity
molt identity show --keypair <path>          # Show identity
molt init --output <path>                    # Init validator keypair

Staking

molt stake add <amount>                      # Stake MOLT
molt stake remove <amount>                   # Unstake MOLT
molt stake status                            # Staking status
molt stake rewards                           # View rewards

Governance

molt gov propose <title> <desc>              # Create proposal
molt gov vote <id> <yes/no/abstain>          # Vote
molt gov list [--all]                        # List proposals
molt gov info <id>                           # Proposal details
molt gov execute <id>                        # Execute proposal
molt gov veto <id>                           # Veto proposal

Tokens

molt token create <name> <symbol> --wasm <path>  # Deploy token WASM + register
molt token info <token>                      # Token info
molt token mint <token> <amount>             # Mint tokens
molt token send <token> <to> <amount>        # Send tokens
molt token balance <token>                   # Check balance
molt token list                              # List tokens

Account & Contract Inspection

molt account info <address>                  # Account details
molt account history <address> --limit N     # Transaction history
molt contract info <address>                 # Contract details
molt contract logs <address> --limit N       # Contract logs
molt contract list                           # All contracts
molt contract register <addr> --symbol X     # Register in symbol registry
molt network status                          # Network status
molt network peers                           # Connected peers
molt validator info <address>                # Validator details
molt validator performance <address>         # Validator performance

17. Validator Operations

Agent Default: 1-Minute Install And Run

If an agent is asked to install or start a validator on a fresh machine, the default public path is:

  1. Download the latest signed release bundle.
  2. Extract moltchain-validator.
  3. Create a writable state directory.
  4. Start mainnet with seed peers and --auto-update=apply.

Do not default to git clone unless the user explicitly wants source checkout, development, or to modify code.

Linux x86_64:

curl -LO https://github.com/lobstercove/moltchain/releases/latest/download/moltchain-validator-linux-x86_64.tar.gz
curl -LO https://github.com/lobstercove/moltchain/releases/latest/download/SHA256SUMS
grep 'moltchain-validator-linux-x86_64.tar.gz' SHA256SUMS | sha256sum -c -
tar xzf moltchain-validator-linux-x86_64.tar.gz --strip-components=1
chmod +x moltchain-validator
mkdir -p "$HOME/.moltchain/state-mainnet"
./moltchain-validator \
  --network mainnet \
  --p2p-port 8001 \
  --rpc-port 9899 \
  --ws-port 9900 \
  --db-path "$HOME/.moltchain/state-mainnet" \
  --bootstrap-peers seed-01.moltchain.network:8001,seed-02.moltchain.network:8001,seed-03.moltchain.network:8001 \
  --auto-update=apply

macOS Apple Silicon:

curl -LO https://github.com/lobstercove/moltchain/releases/latest/download/moltchain-validator-darwin-aarch64.tar.gz
curl -LO https://github.com/lobstercove/moltchain/releases/latest/download/SHA256SUMS
grep 'moltchain-validator-darwin-aarch64.tar.gz' SHA256SUMS | shasum -a 256 -c -
tar xzf moltchain-validator-darwin-aarch64.tar.gz --strip-components=1
chmod +x moltchain-validator
mkdir -p "$HOME/.moltchain/state-mainnet"
./moltchain-validator \
  --network mainnet \
  --p2p-port 8001 \
  --rpc-port 9899 \
  --ws-port 9900 \
  --db-path "$HOME/.moltchain/state-mainnet" \
  --bootstrap-peers seed-01.moltchain.network:8001,seed-02.moltchain.network:8001,seed-03.moltchain.network:8001 \
  --auto-update=apply

Windows x64 (PowerShell):

Invoke-WebRequest -Uri "https://github.com/lobstercove/moltchain/releases/latest/download/moltchain-validator-windows-x86_64.tar.gz" -OutFile "moltchain-validator-windows-x86_64.tar.gz"
tar -xzf .\moltchain-validator-windows-x86_64.tar.gz --strip-components=1
New-Item -ItemType Directory -Force -Path "$HOME\.moltchain\state-mainnet" | Out-Null
.\moltchain-validator.exe `
  --network mainnet `
  --p2p-port 8001 `
  --rpc-port 9899 `
  --ws-port 9900 `
  --db-path "$HOME\.moltchain\state-mainnet" `
  --bootstrap-peers seed-01.moltchain.network:8001,seed-02.moltchain.network:8001,seed-03.moltchain.network:8001 `
  --auto-update=apply

Join the Mainnet (Quick Start for Agents)

If the machine already has a moltchain-validator binary, agents do not need the full repo checkout. They can join mainnet immediately with the binary plus a writable state directory:

mkdir -p "$HOME/.moltchain/state-mainnet"

moltchain-validator \
  --network mainnet \
  --p2p-port 8001 \
  --rpc-port 9899 \
  --ws-port 9900 \
  --db-path "$HOME/.moltchain/state-mainnet" \
    --bootstrap-peers seed-01.moltchain.network:8001,seed-02.moltchain.network:8001,seed-03.moltchain.network:8001 \
    --auto-update=apply

Download A Release Instead Of Cloning

Preferred agent flow:

  1. Detect platform.
  2. Download the matching GitHub Release archive.
  3. Extract moltchain-validator.
  4. Create a writable state directory.
  5. Start with domain bootstrap peers and --auto-update=apply.

Release URL template:

https://github.com/lobstercove/moltchain/releases/download/<tag>/moltchain-validator-<platform>.tar.gz

Current platform names:

  • linux-x86_64
  • linux-aarch64
  • darwin-x86_64
  • darwin-aarch64
  • windows-x86_64

Linux x86_64:

VERSION=$(curl -fsSL https://api.github.com/repos/lobstercove/moltchain/releases/latest | jq -r .tag_name)
curl -LO "https://github.com/lobstercove/moltchain/releases/download/${VERSION}/moltchain-validator-linux-x86_64.tar.gz"
curl -LO "https://github.com/lobstercove/moltchain/releases/download/${VERSION}/SHA256SUMS"
grep 'moltchain-validator-linux-x86_64.tar.gz' SHA256SUMS | sha256sum -c -
tar xzf moltchain-validator-linux-x86_64.tar.gz --strip-components=1
chmod +x moltchain-validator
mkdir -p "$HOME/.moltchain/state-mainnet"
./moltchain-validator \
  --network mainnet \
  --p2p-port 8001 \
  --rpc-port 9899 \
  --ws-port 9900 \
  --db-path "$HOME/.moltchain/state-mainnet" \
  --bootstrap-peers seed-01.moltchain.network:8001,seed-02.moltchain.network:8001,seed-03.moltchain.network:8001 \
  --auto-update=apply

macOS Apple Silicon:

VERSION=$(curl -fsSL https://api.github.com/repos/lobstercove/moltchain/releases/latest | jq -r .tag_name)
curl -LO "https://github.com/lobstercove/moltchain/releases/download/${VERSION}/moltchain-validator-darwin-aarch64.tar.gz"
curl -LO "https://github.com/lobstercove/moltchain/releases/download/${VERSION}/SHA256SUMS"
grep 'moltchain-validator-darwin-aarch64.tar.gz' SHA256SUMS | shasum -a 256 -c -
tar xzf moltchain-validator-darwin-aarch64.tar.gz --strip-components=1
chmod +x moltchain-validator
mkdir -p "$HOME/.moltchain/state-mainnet"
./moltchain-validator \
  --network mainnet \
  --p2p-port 8001 \
  --rpc-port 9899 \
  --ws-port 9900 \
  --db-path "$HOME/.moltchain/state-mainnet" \
  --bootstrap-peers seed-01.moltchain.network:8001,seed-02.moltchain.network:8001,seed-03.moltchain.network:8001 \
  --auto-update=apply

Windows x64 (PowerShell):

$version = (Invoke-RestMethod https://api.github.com/repos/lobstercove/moltchain/releases/latest).tag_name
Invoke-WebRequest -Uri "https://github.com/lobstercove/moltchain/releases/download/$version/moltchain-validator-windows-x86_64.tar.gz" -OutFile "moltchain-validator-windows-x86_64.tar.gz"
tar -xzf .\moltchain-validator-windows-x86_64.tar.gz --strip-components=1
New-Item -ItemType Directory -Force -Path "$HOME\.moltchain\state-mainnet" | Out-Null
.\moltchain-validator.exe `
  --network mainnet `
  --p2p-port 8001 `
  --rpc-port 9899 `
  --ws-port 9900 `
  --db-path "$HOME\.moltchain\state-mainnet" `
  --bootstrap-peers seed-01.moltchain.network:8001,seed-02.moltchain.network:8001,seed-03.moltchain.network:8001 `
  --auto-update=apply

If a release tag predates Windows packaging, agents should fall back to the source-build workflow on Windows.

What The Validator Does On First Start

Given a fresh --db-path, the validator:

  1. Creates the state directory.
  2. Generates or imports the validator identity there.
  3. Persists validator-local runtime material in that directory.
  4. Connects to seed-01.moltchain.network, seed-02.moltchain.network, and seed-03.moltchain.network.
  5. Syncs the chain and peer graph.
  6. Reuses that same identity on restart if the state directory is preserved.

Agents should treat the state directory as persistent machine-local validator state. The repo checkout is optional; the state directory is not.

For unattended updates, agents should prefer running the validator under a restart supervisor or service manager. --auto-update=apply stages the signed replacement binary and requests a restart; it is not a substitute for process supervision.

If the machine only has source code, use the repo workflow below:

# 1. Prerequisites: Rust 1.88+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"

# 2. Clone and build
git clone https://github.com/lobstercove/moltchain.git
cd moltchain
cargo build --release

# 3. Start a mainnet validator (bootstraps from seed nodes automatically)
./target/release/moltchain-validator \
    --p2p-port 8001 \
    --rpc-port 9899 \
    --ws-port 9900 \
    --db-path ./data/state-mainnet \
  --bootstrap-peers seed-01.moltchain.network:8001,seed-02.moltchain.network:8001,seed-03.moltchain.network:8001

On first start the validator:

  • Generates a keypair → saved to ./data/state-mainnet/validator-keypair.json
  • Syncs genesis + state from seed nodes
  • Receives a 100K MOLT bootstrap grant (for the first 200 validators)
  • Begins block production after sync completes

The identity persists across restarts (stored in the data directory, not $HOME).

Configuration Reference

Flag Default Description
--p2p-port 7001 P2P gossip port
--rpc-port 8899 JSON-RPC HTTP port
--ws-port 8900 WebSocket port
--db-path ./data/state-{p2p_port} State database directory
--bootstrap-peers none Comma-separated host:port list
--keypair auto Path to validator keypair JSON
--import-key Import keypair from another machine
--genesis Path to genesis config (only for genesis node)
--listen-addr 0.0.0.0 Bind address for all servers
--dev-mode off Disable machine fingerprint (testnet only)
--auto-update check check / apply / off
--max-restarts 50 Max auto-restarts before giving up

Seed Validators (Mainnet)

Region Address
US East (Virginia) seed-01.moltchain.network:8001
EU West (France) seed-02.moltchain.network:8001
AP Southeast (Singapore) seed-03.moltchain.network:8001

Prefer domains over raw IPs in agent prompts and operational scripts. DNS lets bootstrap infrastructure move without changing the validator command or republishing the binary.

RPC Endpoints (Mainnet Production)

Service URL
RPC https://rpc.moltchain.network
WebSocket wss://ws.moltchain.network

Testnet (for Development)

./target/release/moltchain-validator \
    --p2p-port 7001 \
    --rpc-port 8899 \
    --ws-port 8900 \
    --db-path ./data/state-testnet \
    --dev-mode \
  --bootstrap-peers seed-01.moltchain.network:7001,seed-02.moltchain.network:7001,seed-03.moltchain.network:7001

Mainnet

./target/release/moltchain-validator \
    --p2p-port 8001 \
    --rpc-port 9899 \
    --ws-port 9900 \
    --db-path ./data/state-mainnet \
  --bootstrap-peers seed-01.moltchain.network:8001,seed-02.moltchain.network:8001,seed-03.moltchain.network:8001

Start / Stop / Reset (Scripts)

bash moltchain-start.sh mainnet      # Start mainnet validator
bash moltchain-start.sh testnet      # Start testnet validator
bash moltchain-stop.sh               # Stop all
bash reset-blockchain.sh             # Full reset (preserves ZK keys)

Identity & Keypair Management

Validator identity keypair location (in priority order):

  1. --keypair <path> CLI argument
  2. MOLTCHAIN_VALIDATOR_KEYPAIR env var
  3. {db-path}/validator-keypair.json (data directory — recommended)
  4. ~/.moltchain/validators/validator-{port}.json (legacy)
  5. Auto-generated if none found

To migrate a validator to a new machine:

# Export keypair from old machine
scp old-machine:path/to/data/state-mainnet/validator-keypair.json ./my-validator.json

# Import on new machine
./target/release/moltchain-validator \
    --import-key ./my-validator.json \
    --p2p-port 8001 \
  --bootstrap-peers seed-01.moltchain.network:8001,seed-02.moltchain.network:8001,seed-03.moltchain.network:8001

Auto-Update

./target/release/moltchain-validator --auto-update=check           # Check only
./target/release/moltchain-validator --auto-update=apply           # Download + restart
./target/release/moltchain-validator --update-check-interval=300   # Custom interval (seconds)
./target/release/moltchain-validator --update-channel=beta         # Channel selection

Exit code 75 → restart with new binary. Rollback: 3 crashes within 60s → automatic rollback.

Docker

docker-compose up -d

Systemd (VPS Deployment)

sudo bash deploy/setup.sh testnet mainnet   # Creates moltchain user, env files, systemd units
sudo systemctl enable moltchain-validator-testnet moltchain-validator-mainnet
sudo systemctl start moltchain-validator-testnet moltchain-validator-mainnet

CRITICAL — VPS State Directory Convention:

All systemd services on production VPSes use /var/lib/moltchain/ as the base directory:

Path Purpose
/var/lib/moltchain/state-testnet Testnet chain state (RocksDB)
/var/lib/moltchain/state-mainnet Mainnet chain state (RocksDB)
/var/lib/moltchain/contracts/ Compiled WASM contract artifacts
/var/lib/moltchain/faucet-keypair-testnet.json Faucet signing keypair
/var/lib/moltchain/airdrops.json Faucet airdrop tracking
/var/lib/moltchain/custody-db Custody bridge state (testnet)
/var/lib/moltchain/custody-db-mainnet Custody bridge state (mainnet)
/usr/local/bin/moltchain-* Installed binaries

Never run validators manually from ~/moltchain/data/state-* on VPSes — this creates a separate state directory from what systemd uses and causes split-brain / network stalls. The systemd unit sets HOME=/var/lib/moltchain and MOLTCHAIN_HOME=/var/lib/moltchain.

Or manually:

sudo cp deploy/moltchain-validator.service /etc/systemd/system/
sudo systemctl enable moltchain-validator
sudo systemctl start moltchain-validator

macOS LaunchAgent

Create wrapper script and LaunchAgent plist for an auto-starting background service. The wrapper downloads the latest release by semver (not GitHub "latest" publish date) and installs bundled ZK keys.

# 1. Create wrapper script
mkdir -p ~/.moltchain/bin ~/.moltchain/state-mainnet ~/.moltchain/logs
cat > ~/.moltchain/bin/moltchain-service.sh << 'SCRIPT'
#!/bin/bash
set -euo pipefail
INSTALL_DIR="$HOME/.moltchain/bin"
BINARY="$INSTALL_DIR/moltchain-validator"
REPO="lobstercove/moltchain"
ARCH=$(uname -m)
case "$ARCH" in
    arm64|aarch64) ASSET="moltchain-validator-darwin-aarch64.tar.gz" ;;
    x86_64)        ASSET="moltchain-validator-darwin-x86_64.tar.gz" ;;
esac
mkdir -p "$INSTALL_DIR" "$HOME/.moltchain/state-mainnet" "$HOME/.moltchain/logs"
if [ ! -x "$BINARY" ]; then
    TMPDIR=$(mktemp -d); trap 'rm -rf "$TMPDIR"' EXIT
    VERSION=$(/usr/bin/curl -fsSL "https://api.github.com/repos/$REPO/releases" \
        | /usr/bin/python3 -c "
import sys, json
releases = [r for r in json.load(sys.stdin) if not r['draft'] and not r['prerelease']]
releases.sort(key=lambda r: [int(x) for x in r['tag_name'].lstrip('v').split('.')], reverse=True)
print(releases[0]['tag_name'])")
    /usr/bin/curl -fSL -o "$TMPDIR/$ASSET" "https://github.com/$REPO/releases/download/${VERSION}/${ASSET}"
    /usr/bin/curl -fSL -o "$TMPDIR/SHA256SUMS" "https://github.com/$REPO/releases/download/${VERSION}/SHA256SUMS"
    cd "$TMPDIR"; grep "$ASSET" SHA256SUMS | shasum -a 256 -c -
    tar xzf "$ASSET" --strip-components=1; mv moltchain-validator "$BINARY"; chmod +x "$BINARY"
    if [ -d "zk" ]; then mkdir -p "$HOME/.moltchain/zk"; cp zk/*.bin "$HOME/.moltchain/zk/"; fi
    trap - EXIT; rm -rf "$TMPDIR"
fi
exec "$BINARY" --network mainnet --p2p-port 8001 --rpc-port 9899 --ws-port 9900 \
    --db-path "$HOME/.moltchain/state-mainnet" \
    --bootstrap-peers seed-01.moltchain.network:8001,seed-02.moltchain.network:8001,seed-03.moltchain.network:8001 \
    --auto-update=apply
SCRIPT
chmod +x ~/.moltchain/bin/moltchain-service.sh

# 2. Create LaunchAgent plist
cat > ~/Library/LaunchAgents/network.moltchain.validator.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key><string>network.moltchain.validator</string>
    <key>ProgramArguments</key><array><string>/bin/bash</string><string>$HOME/.moltchain/bin/moltchain-service.sh</string></array>
    <key>RunAtLoad</key><true/>
    <key>KeepAlive</key><true/>
    <key>ThrottleInterval</key><integer>15</integer>
    <key>StandardOutPath</key><string>$HOME/.moltchain/logs/validator.log</string>
    <key>StandardErrorPath</key><string>$HOME/.moltchain/logs/validator.log</string>
    <key>EnvironmentVariables</key><dict><key>RUST_LOG</key><string>info</string></dict>
</dict>
</plist>
EOF

# 3. Load
launchctl load ~/Library/LaunchAgents/network.moltchain.validator.plist

Service management:

launchctl load ~/Library/LaunchAgents/network.moltchain.validator.plist     # Start
launchctl unload ~/Library/LaunchAgents/network.moltchain.validator.plist   # Stop
tail -f ~/.moltchain/logs/validator.log                                     # Logs
launchctl list | grep moltchain                                             # Status
# Force re-download after new release:
launchctl unload ~/Library/LaunchAgents/network.moltchain.validator.plist
rm ~/.moltchain/bin/moltchain-validator
launchctl load ~/Library/LaunchAgents/network.moltchain.validator.plist

macOS file layout:

Path Purpose
~/.moltchain/bin/moltchain-validator Binary
~/.moltchain/bin/moltchain-service.sh Wrapper script
~/.moltchain/state-mainnet/ Blockchain state DB
~/.moltchain/zk/ ZK verification & proving keys
~/.moltchain/logs/validator.log Log file
~/Library/LaunchAgents/network.moltchain.validator.plist LaunchAgent plist

Windows Service (NSSM)

# 1. Download and extract
$Version = "v0.2.14"
$InstallDir = "$env:LOCALAPPDATA\MoltChain"
New-Item -ItemType Directory -Force -Path "$InstallDir\bin","$InstallDir\state-mainnet","$InstallDir\logs","$InstallDir\zk"
$Url = "https://github.com/lobstercove/moltchain/releases/download/$Version/moltchain-validator-windows-x86_64.tar.gz"
Invoke-WebRequest -Uri $Url -OutFile "$env:TEMP\moltchain.tar.gz"
tar -xzf "$env:TEMP\moltchain.tar.gz" -C "$InstallDir\bin" --strip-components=1
if (Test-Path "$InstallDir\bin\zk") { Copy-Item "$InstallDir\bin\zk\*" "$InstallDir\zk\" }

# 2. Install NSSM (https://nssm.cc/download) and create service
nssm install MoltChainValidator "$InstallDir\bin\moltchain-validator.exe"
nssm set MoltChainValidator AppParameters "--network mainnet --p2p-port 8001 --rpc-port 9899 --ws-port 9900 --db-path $InstallDir\state-mainnet --bootstrap-peers seed-01.moltchain.network:8001,seed-02.moltchain.network:8001,seed-03.moltchain.network:8001 --auto-update=apply"
nssm set MoltChainValidator AppDirectory "$InstallDir"
nssm set MoltChainValidator AppStdout "$InstallDir\logs\validator.log"
nssm set MoltChainValidator AppStderr "$InstallDir\logs\validator.log"
nssm set MoltChainValidator AppEnvironmentExtra "RUST_LOG=info" "USERPROFILE=$InstallDir"
nssm set MoltChainValidator Start SERVICE_AUTO_START
nssm set MoltChainValidator AppRestartDelay 10000

# 3. Start
nssm start MoltChainValidator

Windows service management:

nssm status MoltChainValidator
nssm start MoltChainValidator
nssm stop MoltChainValidator
nssm restart MoltChainValidator
nssm remove MoltChainValidator confirm     # Uninstall
Get-Content "$env:LOCALAPPDATA\MoltChain\logs\validator.log" -Tail 50 -Wait

ZK Verification Keys

All validators must use identical ceremony ZK keys. Keys are shipped in the release tarball under zk/. The validator loads them from (priority order):

  1. Env vars: MOLTCHAIN_ZK_SHIELD_VK_PATH, MOLTCHAIN_ZK_UNSHIELD_VK_PATH, MOLTCHAIN_ZK_TRANSFER_VK_PATH
  2. Shared cache: ~/.moltchain/zk/ (Linux/macOS) or %LOCALAPPDATA%\MoltChain\zk\ (Windows)
  3. Bundled zk/ next to binary (auto-copied to shared cache)

If missing, shielded transactions are unavailable but the validator still functions.

Manual install:

mkdir -p ~/.moltchain/zk
cp /path/to/release/zk/*.bin ~/.moltchain/zk/
sha256sum ~/.moltchain/zk/vk_*.bin
# af980fb4...  vk_shield.bin
# e368eeaf...  vk_transfer.bin
# f39b6e2e...  vk_unshield.bin

Health Check

curl -s http://localhost:9899 -d '{"jsonrpc":"2.0","id":1,"method":"getHealth"}' | jq .
# → {"status":"ok","slot":12345}

18. Contract Development

See docs/guides/CONTRACT_DEVELOPMENT.md for the complete guide.

Two SDKs (Different Packages)

SDK Package Purpose Environment
Contract SDK moltchain-contract-sdk Write on-chain WASM contracts #![no_std], wasm32-unknown-unknown
Client SDK (Rust) moltchain-client-sdk Call RPC from Rust apps tokio, reqwest

molt deploy vs molt token create

Command What it does Fee
molt deploy contract.wasm Deploy WASM contract (no symbol registration) 25.001 MOLT
molt deploy wasm --symbol X --name Y --template token Deploy + auto-register in symbol registry 25.001 MOLT
molt deploy wasm --symbol X --supply 1000000 --decimals 9 Deploy + register with initial total supply 25.001 MOLT
molt deploy wasm --metadata '{"website":"...","logo":"..."}' Deploy with custom metadata JSON 25.001 MOLT
molt token create "Name" SYM --wasm token.wasm Deploy token WASM + register with template="token" 25.001 MOLT
molt contract register <addr> --symbol X Retroactively register deployed contract in symbol registry 0.001 MOLT

All tokens on MoltChain are WASM contracts. Use molt deploy --symbol or molt token create --wasm to deploy and register in one step. Use molt contract register to fix contracts deployed without symbol metadata.

--supply <amount> sets initial total supply (in whole tokens, auto-converted to shells via decimals). --metadata <json> attaches arbitrary metadata to the symbol registry entry. After deploy, the CLI automatically verifies the contract is live on-chain by polling getAccountInfo.

Template Categories

The --template flag sets the contract category in the symbol registry. The explorer uses this to filter and display contracts. Common values (matching genesis):

Template Explorer Category Used By
token Token Fungible tokens (MT-20)
wrapped Wrapped Bridge-wrapped tokens (MUSD, WSOL, WETH, WBNB)
nft NFT NFT collections (MT-721)
marketplace NFT NFT marketplaces
auction NFT Auction contracts
dex DEX Exchange contracts
defi DeFi General DeFi protocols
lending DeFi Lending protocols
bridge DeFi Cross-chain bridges
oracle DeFi Price oracles
governance Governance DAO governance
identity Infra Identity/DID
launchpad Infra Token launchpads
vault Infra Vault contracts
payments Infra Payment processors
bounty Infra Bounty boards
compute Infra Compute markets
storage Infra Storage protocols

The template is a free-form string — any value is accepted. Unrecognized values default to "Infra" in the explorer. The Programs Playground uses mt20 (→ Token) and mt721 (→ NFT) as aliases.

Contract Function Convention

#[no_mangle]
pub extern "C" fn my_function(addr_ptr: *const u8, amount: u64) -> u32 {
    // addr_ptr = 32-byte address pointer
    // Returns: 1 = success, 0 = failure
    1
}

Deploy Fee Refund

If deployment fails (invalid WASM, duplicate address, etc.), the 25 MOLT deploy premium is automatically refunded on-chain. Only the 0.001 MOLT base fee is kept. This includes failures in b_put_transaction and commit_batch paths — the premium refund is guaranteed regardless of which stage fails. Failed transactions are stored on-chain and queryable via getTransaction.

Deploy Output & Auto-Register Fallback

When you deploy with --symbol, the CLI:

  1. Sends the deploy transaction (Phase 1)
  2. Polls up to 10 times (1s apart) to verify the contract account is live on-chain (Phase 2)
  3. Checks if the symbol was registered in the symbol registry (Phase 3)
  4. If the symbol is not found after 3 retries, the CLI automatically sends a register-symbol transaction as a fallback
  5. Reports final status with the contract address and symbol registration result

This means user-deployed contracts get the same name, category, and metadata in the explorer as genesis contracts — no manual molt contract register step needed.

Contract SDK Modules

Module Key Functions
storage storage_get(key), storage_set(key, val), storage::remove(key)
contract contract::args(), contract::set_return(data)
event event::emit(json_str)
log log::info(msg)
token Token::new(name, symbol, decimals, prefix) — MT-20
nft NFT::new(name, symbol) — MT-721
crosscall CrossCall::new(target, fn, args), call_contract(call)
dex Pool::new(token_a, token_b) — AMM
crypto poseidon_hash(left: &[u8;32], right: &[u8;32]) -> [u8;32] — BN254 Poseidon
test_mock Thread-local mocks for native testing

Quick Start

# Add WASM target
rustup target add wasm32-unknown-unknown

# Build contract
cargo build --target wasm32-unknown-unknown --release

# Test locally
cargo test

# Deploy with symbol registration (need 25.001 MOLT)
molt deploy target/wasm32-unknown-unknown/release/my_contract.wasm \
  --symbol MYTK --name "My Token" --template token --decimals 9 \
  --supply 1000000 --metadata '{"website":"https://example.com"}'

# Or deploy without registration
molt deploy target/wasm32-unknown-unknown/release/my_contract.wasm

# Retroactively register an already-deployed contract
molt contract register <address> --symbol MYTK --name "My Token" --template token

# Call a function
molt call <address> <function_name> [args]

19. Build & Test

Build

cargo build --release                                    # Full workspace
cargo build --release -p moltchain-validator              # Single crate
rustup target add wasm32-unknown-unknown                  # WASM target
bash scripts/build-all-contracts.sh                       # All 29 contracts

Test Suites

Suite Command Tests
Core unit cargo test -p moltchain-core Rust unit tests
RPC unit cargo test -p moltchain-rpc RPC tests
Validator unit cargo test -p moltchain-validator Includes auto-update
All Cargo cargo test --workspace ~1,296 tests
DEX unit node dex/dex.test.js 1,877 JS tests
E2E transactions node tests/e2e-transactions.js 26 tests
E2E production node tests/e2e-production.js 180 tests
E2E DEX node tests/e2e-dex.js 87 tests
E2E volume node tests/e2e-volume.js 115+ tests
E2E launchpad node tests/e2e-launchpad.js 48 tests
E2E prediction node tests/e2e-prediction.js 49 tests
Contracts write python tests/contracts-write-e2e.py 157 scenarios

All E2E tests require a running validator (bash moltchain-start.sh testnet).


Last updated: June 2025