Smart Contracts
Deployed Addresses

Deployed Addresses

The addresses below are the shared contracts on æternity mainnet (ae_mainnet) and testnet (ae_uat). Per-community contracts (token, sale, DAO, community management) are deployed by the factory and resolved per token. See Reading addresses at runtime.

Mainnet (ae_mainnet)

ContractAddress
CommunityFactoryct_25cqTw85wkF5cbcozmHHUCuybnfH9WaRZXSgEcNNXG9LsCJWTN
AffiliationTreasuryct_2GG42rs2FDPTXuUCWHMn98bu5Ab6mgNxY7KdGAKUNsrLqutNxZ
ProtocolDAO token (AEX-9)ct_dsa6octVEHPcm7wRszK6VAjPp1FTqMWa7sBFdxQ9jBT35j6VW
Tipping v3ct_2Hyt9ZxzXra5NAzhePkRsDPDWppoatVD7CtHnUoHVbuehwR8Nb
Governance registryct_ouZib4wT9cNwgRA1pxgA63XEUd8eQRrG8PcePDEYogBc1VYTq
DEX factoryct_2mfj3FoZxnhkSw5RZMcP8BfPoB1QR4QiYGNCdkAvLZ1zfF6paW
DEX routerct_azbNZ1XrPjXfqBqbAh1ffLNTQ1sbnuUDFvJrXjYz7JQA1saQ3
WAE (wrapped AE)ct_J3zBY8xxjsRr3QojETNw48Eb38fjvEuJKkQ6KzECvubvEcvCa
aeETHct_ryTY1mxqjCjq1yBn9i6HDaCSdA6thXUFZTA84EMzbWd1SLKdh

The mainnet factory was deployed at key block height 1089546. Start an indexer backfill of factory events from there. The governance registry is older: its backfill starts at height 164578.

Testnet (ae_uat)

ContractAddress
CommunityFactoryct_vLKrYRCthfViqUuWFKGYgz7kxhvrsdAoKhZPXqzxcaEFRkZy1
AffiliationTreasuryct_2QmAcPxY4TBbFmkSUhxU4UTwoRot8SMmZzaAKL6oyHmQqRL1rK
ProtocolDAO token (AEX-9)ct_2cyV58CrBwi2k4kvP3mN517C1NH21zfxxYmaAyb41GXdXSsRvN
Tipping v3ct_2J1wuuw9urs9ADBh5QbvuPyUCLdKbW5YRkfhgPoN7rGjBbPiBW
Governance registryct_2nritSnqW6zooEL4g2SMW5pf12GUbrNyZ17osTLrap7wXiSSjf
DEX factoryct_NhbxN8wg8NLkGuzwRNDQhMDKSKBwDAQgxQawK7tkigi2aC7i9
DEX routerct_MLXQEP12MBn99HL6WDaiTqDbG4bJQ3Q9Bzr57oLfvEkghvpFb
WAE (wrapped AE)ct_JDp175ruWd7mQggeHewSLS1PFXt9AzThCDaFedxon8mF8xTRF
aeETHct_WVqAvLQpvZCgBg4faZLXA1YBj43Fxj91D33Z8K7pFsY8YCofv

The testnet factory was deployed at key block height 1097291; the testnet governance registry backfill starts at height 168710.

Reading addresses at runtime

Everything hangs off the factory, so one lookup resolves the whole graph. The Superhero web app fetches the active factory from the API rather than hardcoding it.

Get the factory from the API

curl -s https://api.superhero.com/api/factory

The response is the community factory schema:

address                   ct_... the CommunityFactory
deployed_at_block_height  int, the key block the factory was deployed at
bctsl_aex9_address        ct_... the ProtocolDAO token
affiliation_address       ct_... the AffiliationTreasury
collections               map of collection id -> collection data

Collection ids have the shape <name>-<creator address>, for example WORDS-ak_.... create_collection stores the submitted name, a dash, and the caller's address, so the id you pass to create_community is the full concatenated string, not the bare name.

Read shared addresses from the factory

Every shared address is an entrypoint on the factory, so you can resolve them on chain without the API:

import { AeSdk, Node, Contract } from '@aeternity/aepp-sdk';
import fs from 'fs';
 
const aeSdk = new AeSdk({
  nodes: [{ name: 'mainnet', instance: new Node('https://mainnet.aeternity.io') }],
});
 
const factory = await Contract.initialize({
  aci: JSON.parse(fs.readFileSync('./contracts/CommunityFactory.aci.json', 'utf8')),
  address: 'ct_25cqTw85wkF5cbcozmHHUCuybnfH9WaRZXSgEcNNXG9LsCJWTN',
  onNode: aeSdk.api,
});
 
const treasury   = await factory.affiliation_treasury().then((r) => r.decodedResult);
const daoToken   = await factory.protocol_dao_token().then((r) => r.decodedResult);
const curve      = await factory.bonding_curve().then((r) => r.decodedResult);
 
console.log({ treasury, daoToken, curve });

affiliation_treasury(), protocol_dao_token() and bonding_curve() are non-stateful reads: they cost nothing and need no account.

Resolve per-community contracts

Given a collection id and a token name:

EntrypointReturns
get_token_sale(collection_name, name)the AffiliationBondingCurveTokenSale address
token_contract(collection_name, name)the community's AEX-9 token address
get_community_management(token_sale)the CommunityManagement address
has_community(collection_name, name)whether the name is taken

The factory has no getter for the DAO. Read it from the sale contract's state (get_state().dao_contract), or capture all three addresses from the CreateCommunity event, which carries the DAO, the sale and the community management contract.

If you already have a sale address, GET /api/tokens/<sale address> returns the same set of addresses without any chain calls.

Related