-
Notifications
You must be signed in to change notification settings - Fork 14
Token Registry
This is a system smart contract which is publicly available for everyone to use.
The TokenRegistry contract will be used for displaying all the tokens available on aeternity blockchain with the relevant information - total_supply
, balances
, owners
, meta_info
, etc.
The waellet will be auto fetching the user balances without the need to manually entering the address for each contract.
Note: Token registry contracts will be slightly modified and re-deployed after Lima protocol upgrade, for more efficiency. The state will be migrated and the new contract addresses will published here.
Network | Contract address |
---|---|
Mainnet | ct_UAzV9RcXEMsFcUCmrPN4iphbZroM7EHk3wvdidDYgZGGBo3hV |
Testnet | ct_UAzV9RcXEMsFcUCmrPN4iphbZroM7EHk3wvdidDYgZGGBo3hV |
The contract used in waellet is located at these addresses. We suggest other interfaces, decentralized applications, decentralized exchanges, and wallets use the same addresses in order to have an on-chain synced library of tokens without sacrificing user experience.
If anyone wants to add a new token to the Token Registry contract, they should call add_token(token: Token)
method, providing the AEX-9 (aeternity fungible token) token contract address (ex. ct_...
).
Note: The caller will pay for the tx fees for storing the new address in the smart contract's state.
contract Token =
record meta_info =
{ name : string
, symbol : string
, decimals : int }
entrypoint meta_info : () => meta_info
entrypoint total_supply : () => int
entrypoint owner : () => address
entrypoint balances : () => map(address, int)
entrypoint balance : (address) => option(int)
entrypoint transfer : (address, int) => ()
contract TokenRegistry =
record state = { tokens: map(Token, Token.meta_info) }
stateful entrypoint init() = { tokens = {} }
stateful entrypoint add_token(token : Token) : () =
put(state{ tokens[token] = token.meta_info() })
entrypoint get_all_tokens() : map(Token, Token.meta_info) = state.tokens
entrypoint get_token_meta_info(token : Token) : Token.meta_info = token.meta_info()
entrypoint get_token_balances(token : Token) : map(address, int) = token.balances()
entrypoint get_token_balance(token : Token, account: address) : option(int) = token.balance(account)
entrypoint get_token_owner(token : Token) : address = token.owner()
entrypoint get_token_total_supply(token : Token) : int = token.total_supply()
Source code: waellet/token-registry
Token registry migrator
contract Token =
record meta_info =
{ name : string
, symbol : string
, decimals : int }
entrypoint meta_info : () => meta_info
entrypoint total_supply : () => int
entrypoint owner : () => address
entrypoint balances : () => map(address, int)
entrypoint balance : (address) => option(int)
entrypoint transfer : (address, int) => unit
contract TokenRegistry =
entrypoint add_token : (Token) => unit
entrypoint get_all_tokens : () => map(Token, Token.meta_info)
entrypoint get_token_meta_info : (Token) => Token.meta_info
entrypoint get_token_balances : (Token) => map(address, int)
entrypoint get_token_balance : (Token, address) => option(int)
entrypoint get_token_owner : (Token) => address
entrypoint get_token_total_supply : (Token) => int
contract GetTokenRegistryState =
entrypoint get_state(registry: TokenRegistry) : map(Token, Token.meta_info) = registry.get_all_tokens()