æternity Blockchain
AEX Standards

AEX Standards

AEX ("æternity expansion") proposals are æternity's application-layer standards, the equivalent of Ethereum's ERCs. Superhero depends heavily on one of them, AEX-9, the fungible token standard, and touches a few others through its wallet stack.

AEX-9: fungible tokens

Every Superhero community token and the ProtocolDAO token is an AEX-9 contract. That is why a token you mint on Superhero shows up in any æternity wallet and on æScan (opens in a new tab) without Superhero having to integrate with them.

AEX-9 is inspired by ERC-20 but deliberately smaller: the base interface is the read functions plus transfer, and everything else (allowances, minting, burning, swapping) is an optional extension. A contract advertises which extensions it implements through aex9_extensions().

The interface

Non-stateful entrypoints can be dry-run for free; stateful ones need a signed transaction.

Reads

EntrypointReturnsNotes
aex9_extensions()list(string)Which optional extensions this contract implements
meta_info()recordname, symbol, decimals
total_supply()intIn token-decimals, not whole tokens
owner()addressThe minting authority
balance(account)option(int)An option, not an int; see below
balances()mapEvery holder at once
allowance(accounts)option(int)Keyed on a from/for pair
allowance_for_caller(from)option(int)Convenience for the common case
allowances()mapEvery allowance at once
swapped()map of address to intMigration bookkeeping

Writes (all stateful)

EntrypointExtensionPurpose
transfer(to, value)baseMove your own tokens
create_allowance(for, value)allowanceAuthorise a spender
change_allowance(for, delta)allowanceAdjust by a delta
reset_allowance(for)allowanceRevoke
transfer_allowance(from, to, value)allowanceSpend someone else's authorised balance
mint(account, value)mintableOwner only
burn(value)burnableDestroy your own
swap()swappableMigrate a legacy balance
check_swap(account)swappableInspect a migration

init(name, decimals, symbol, initial_owner_balance) is the deploy-time constructor; initial_owner_balance is an option(int).

Coming from ERC-20

  1. balance returns an option. An address that has never held the token returns None, not Some(0). Handle the empty case explicitly.
  2. Allowances are three calls, not one. ERC-20's approve is split into create_allowance (for an allowance that does not exist yet), change_allowance (relative) and reset_allowance. There is no single idempotent setter, so check whether an allowance exists before you write one.
  3. transfer_allowance is transferFrom. Same withdraw pattern, different name.
  4. Extensions are declared, not assumed. Call aex9_extensions() before assuming mint or burn exists. A minimal AEX-9 token has neither. A Superhero community token returns four extensions; the DEX's WAE contract and every liquidity-pool token return ["allowances"] only, because their supply changes through deposit, withdraw, mint and burn paths that are not AEX-9 entrypoints.

Amounts are integers scaled by the token's own decimals from meta_info(), which is not necessarily 18. See AE & Gas.

What a Superhero community token implements

Every community token is created by the sale contract as a FungibleTokenFull, the "full" variant of the reference implementation (aeternity/aeternity-fungible-token v2.2.0), and the ProtocolDAO token the same way. aex9_extensions() on any of them returns:

["allowances", "mintable", "burnable", "swappable"]
ExtensionWhere Superhero depends on it
mintablebuy on the sale contract calls mint(Call.caller, count)
burnablesell calls burn(count)
allowancessell calls transfer_allowance; DAOVote.vote locks tokens the same way
swappableNot used by Superhero; it comes with the reference variant

decimals is 18 for every community token: the factory's decimals() returns 18 and the sale contract's init requires decimals == bonding_curve.supported_decimals(), which is also 18.

Read AEX-9 balances without a contract call

The middleware indexes AEX-9 holdings, so a wallet view needs one paged request rather than one contract call per token:

GET  <MIDDLEWARE_URL>/v2/aex9/account-balances/ak_...?limit=100

Note the v2: the AEX-9 balance route is on middleware v2, while transaction lookups use v3. See Networks & Endpoints.

The other AEX standards

StandardSubjectStatusSuperhero's relationship to it
AEX-2Wallet-to-æpp communicationWithdrawn, but still the js-sdk's reference implementationUsed: connecting a wallet runs the AEX-2 RPC flow (walletDetector over a BrowserWindowMessageConnection, then connectToWallet)
AEX-3Encrypted secret storage (keystore JSON)ActiveRelevant if you import a keystore file
AEX-8Message signingDraftRelevant to any off-chain signature, including the tipping contract's signed messages
AEX-9Fungible tokensReviewUsed everywhere
AEX-10BIP32 derivation path for deterministic walletsFinalApplies to any mnemonic-based æternity wallet; see Accounts & Keys
AEX-130æpp meta-information formatDraftNot used
AEX-141Non-fungible tokensReviewNot used; Superhero has no NFT feature

AEX-9's status is Review and nothing supersedes it. Every æternity wallet, explorer and the middleware's AEX-9 indexing are built against it as written.

Related