Smart Contracts
Overview

Smart Contracts

Every on-chain rule in Superhero lives in a Sophia contract running on the FATE virtual machine. These pages are the contract-level reference: what each contract does, the exact signature of every entrypoint, the record and variant types you need to build arguments, the events each one emits, and how to call all of it from JavaScript.

The contract suite

ContractRole
Tipping.aes (v3)Post registry and delegated posting
CommunityFactory.aesCollections, community deployment, ProtocolDAO minting
AffiliationBondingCurveTokenSale.aesBuy and sell against the curve, affiliation fees
BondingCurveExponential.aesPrice computation
BondingCurve.aesThe curve interface the sale calls through
DAO.aesOne community's treasury, vote creation and execution
DAOVote.aesOne proposal and its locked stake
ReplaceableDAO.aesThe interface a replacement DAO must implement
CommunityManagement.aesModerators, write threshold, community metadata
AffiliationTreasury.aesReferral accounting, invite codes, payouts
FungibleTokenFull.aesThe AEX-9 token implementation
Registry.aes / Poll.aesæternity governance polls
AddressLinkIdentity: provider-keyed links from an address to an X handle, AENS name or nostr key

DAO, DAOVote, CommunityManagement, AffiliationTreasury, VoteSubjects, Set, Frac and FungibleTokenFull have no ACI file of their own: the compiler inlines them into CommunityFactory.aci.json. Load the factory ACI when you need any of those interfaces.

How the pieces fit together

CommunityFactory                      one per network, deployed once
  ├── create_collection(...)          registers a naming namespace (555 AE, burned)
  └── create_community(...)           deploys four contracts in one transaction:
        ├── CommunityManagement       moderators, mute list, write threshold
        ├── DAO                       owner + beneficiary of the sale
        │     └── add_vote(...)       deploys a DAOVote (555 AE)
        └── AffiliationBondingCurveTokenSale
              ├── FungibleTokenFull   the community's AEX-9 token, created in the sale's init
              ├── buy                 mints tokens, splits the 1% spread
              └── sell                burns tokens, pays out AE

Three contracts sit outside that tree and are shared by every community: BondingCurveExponential, which prices every trade; AffiliationTreasury, which accounts for referral rewards across all sales; and the ProtocolDAO AEX-9 token, which the factory mints into every buyer's account.

buy_with_affiliation is factory-only, used for the creator's initial buy. An ordinary buy already credits the buyer's own referral chain. See AffiliationBondingCurveTokenSale.

Sophia and FATE

Sophia is a strongly typed functional language in the ML family. A contract has exactly one state value, replaced rather than mutated, so there is no partially updated storage for a failed call to leave behind. Every FATE instruction is typed, and a type mismatch aborts the call and reverts all changes. See Sophia and FATE.

Cross-cutting pages

PageWhat it gives you
Deployed AddressesEvery shared address, per network, and how to resolve per-community contracts at runtime
Calling ContractsA complete runnable SDK example, dry runs, gas, events, reverts
EventsOne cross-contract event catalogue, with topic hashes
Security ModelThe cryptographic, economic and governance mechanisms that protect users

Related