Skip to content

Smart Contract

The smart contract lives in move/forum/sources/forum.move and is the core of the system. All state changes happen on-chain.

6 Shared Objects

The contract has been refactored from a single monolithic Forum object into 6 parallel shared objects, enabling concurrent transaction execution on IOTA:

ObjectTypeDescription
ForumSharedForum data, categories, global configuration
UserRegistrySharedUser profiles, roles, follow/unfollow relationships
TreasurySharedFund management, fee collection, admin withdrawals
SubscriptionStoreSharedSubscription tiers, user subscription status and renewals
MarketplaceStoreSharedPaid content listings, purchasable badges
GovernanceStoreSharedPolls with options/votes, governance proposals with quorum and deadline
AdminCapOwnedCapability object held by the deployer, required for admin operations
EscrowShared (per-trade)Individual escrow instances for 2-of-3 multi-sig trades

Roles

Roles are stored on-chain per user in the UserRegistry object:

ValueRolePermissions
0BANNEDCannot interact
1USERPost, vote, tip, subscribe, purchase, escrow, follow, react, poll, DM
2MODERATORAll USER permissions + create categories, moderate content
3ADMINAll permissions + set roles, configure forum, withdraw treasury

Entry Functions

FunctionMin. RoleDescription
registerNoneRegister a new user in the UserRegistry
post_eventUSERPost a thread, reply, vote, reaction, DM, follow/unfollow, poll vote
mod_post_eventMODERATORCreate category, moderate content
admin_post_eventADMINSet config, manage roles
set_user_roleADMINChange a user’s role
tipUSERSend a tip to a post author
subscribeUSERSubscribe to a creator’s tier
renew_subscriptionUSERRenew an existing subscription
purchase_contentUSERPurchase gated content
purchase_badgeUSERPurchase a badge
configure_tierUSERConfigure subscription tiers for your profile
configure_badgeUSERConfigure badges available for purchase
create_escrowUSERCreate a 2-of-3 multi-sig escrow
mark_deliveredUSERSeller marks escrow as delivered
open_disputeUSEROpen a dispute on an escrow
vote_releaseUSERVote to release escrow funds to seller
vote_refundUSERVote to refund escrow funds to buyer
rate_tradeUSERRate a completed trade (anti-double-rating enforced)
claim_expiredUSERClaim funds from expired escrow
withdraw_fundsADMINWithdraw treasury funds
followUSERFollow another user on-chain
unfollowUSERUnfollow a user on-chain
create_pollUSERCreate a poll with multiple options and deadline
vote_pollUSERVote on a poll option
create_proposalUSERCreate a governance proposal with quorum
vote_proposalUSERVote yes/no on a governance proposal

Events

The contract emits typed events that the backend indexes:

EventTrigger
ForumEventAny forum operation (data is gzipped)
TipEventTip sent to a post author
SubscriptionEventSubscription created or renewed
PurchaseEventContent purchased
BadgeEventBadge purchased
EscrowCreatedNew escrow created
EscrowUpdatedEscrow state changed (delivered, disputed, released, refunded, expired)
RatingEventTrade rated after completion

Event Tags (in ForumEvent data)

TagDescription
FORUM_USERUser registration
FORUM_THREADThread created/edited
FORUM_POSTPost created/edited
FORUM_VOTEVote cast
FORUM_CATEGORYCategory created/edited
FORUM_MODERATIONModeration action
FORUM_ROLERole change
FORUM_CONFIGForum configuration
FORUM_DMDirect message sent
FORUM_FOLLOWUser followed
FORUM_UNFOLLOWUser unfollowed
FORUM_POLLPoll created
FORUM_POLL_VOTEPoll vote cast
FORUM_PROPOSALGovernance proposal created
FORUM_PROPOSAL_VOTEProposal vote cast
FORUM_REACTIONEmoji reaction on a post

Data Encoding

All data stored on-chain is encoded as:

JSON -> gzip -> vector<u8>

This minimizes on-chain storage costs while keeping data structured and recoverable.

Treasury and Fees

The Treasury object holds collected fees:

Fee TypeRate
Marketplace purchases5%
Escrow trades2%

Overpayments are automatically refunded to the sender by the contract.

Testing

The smart contract includes 25 Move tests covering all entry functions, role enforcement, payment flows, escrow lifecycle, governance operations, and edge cases.