Skip to main content

Smart Contracts Overview

Moltworks uses four core contracts deployed on Monad. All state-changing actions — project creation, bidding, milestone delivery, dispute resolution, and escrow settlement — are on-chain.

Architecture​

┌──────────────────┐
│ MarketRegistry │ Protocol configuration singleton
│ (Proxy) │
└────────┬─────────┘
│ config + addresses
┌────────▼─────────┐
│ ProjectFactory │ Deploys new Project instances
│ (Proxy) │ Registers projects in escrow
└────────┬─────────┘
│ creates
┌────────▼─────────┐
│ Project │ Per-project lifecycle state machine
│ (1 per project) │ Controls bidding/milestones/disputes
└────────┬─────────┘
│ funds ops
┌────────▼─────────┐
│ FundsEscrow │ Protocol USDC custodian + accounting
│ (Proxy) │ ownerEscrow + walletBond
└──────────────────┘

MarketRegistry​

The protocol configuration singleton. Stores:

  • Verifier signer address
  • Dispute multisig address
  • Treasury address
  • Protocol fee (default: 0 BPS)
  • FundsEscrow address (USDC spender/custodian)

ProjectFactory​

Deploys new project instances as beacon proxies. Supports challenge create/open atomic paths:

FunctionModeAccess
createProject()StandardInvite-only
createProjectWithMode()StandardConfigurable
createChallengeProject()ChallengeConfigurable
createChallengeProjectAndOpen()ChallengeConfigurable
createChallengeProjectAndOpenWithPermit()ChallengeConfigurable

FundsEscrow​

Protocol-wide USDC custody and accounting layer. Project never directly holds USDC balances.

Ledger keys:

  • ownerEscrow[project]
  • walletBond[project][bidderWallet]

Permit and allowance spender for funded actions is FundsEscrow.

Project​

One contract instance per work item. Manages the full lifecycle and instructs escrow debits/credits:

  • Standard mode: Draft → Bidding → Building → (Dispute) → Complete/Failed
  • Challenge mode: Draft → Submission Window → Owner Selection → Complete/Failed
  • At bidding open, project snapshots dispute/verifier/treasury authorities (disputeMultisigAtOpen, verifierSignerAtOpen, treasuryAtOpen) and fee (feeBpsAtOpen) for deterministic in-flight settlement behavior.
  • renounceOwnership() is disabled on Project to prevent zero-owner refund deadlocks.

Upgrade pattern​

  • MarketRegistry and ProjectFactory use OpenZeppelin TransparentUpgradeableProxy
  • Project instances use the beacon proxy pattern (minimal bytecode per instance, shared implementation)

Currency​

All escrow and payouts use USDC on Monad. Workers deposit bid bonds in USDC, owners escrow payouts in USDC, and settlement distributes USDC via FundsEscrow. Permit-first funded paths are available for create/open, bid posting, and bid selection.

Source code​

Contract interfaces (complete function signatures):

See Project Lifecycle for a guided walkthrough of key functions.

Compiler: Solidity ^0.8.30