# Token Standards

## Token Standards on æternity

The æternity blockchain provides robust support for both fungible and non-fungible tokens through well-defined token standards. These standards ensure interoperability and consistency across different implementations while leveraging the security and efficiency of æternity's native FATE virtual machine. Similar to how ERC-20 and ERC-721 revolutionized token creation on Ethereum, AEX-9 and AEX-141 serve as the foundational standards for building fungible and non-fungible tokens on æternity.

These standards have enabled the development of various DeFi applications and NFT projects within the æternity ecosystem. From decentralized exchanges and tipping systems to complex NFT collections, developers can utilize these battle-tested standards and reference implementations to build secure and scalable token-based applications. The standards are specifically designed to take advantage of æternity's unique features, including state channels for scalability and the Sophia smart contract language for enhanced security.<br>

### Fungible Token Standard (AEX-9)

The [AEX-9](https://github.com/aeternity/AEXs/blob/master/AEXS/aex-9.md) standard, inspired by Ethereum's ERC-20, provides a robust interface for implementing fungible tokens. These tokens are ideal for creating cryptocurrencies, governance tokens, or any other asset where each unit is interchangeable with another. The standard includes essential functions for token transfers, allowances, and balance tracking.

### Non-Fungible Token Standard (AEX-141)

&#x20;The [AEX-141](https://github.com/aeternity/AEXs/blob/master/AEXS/aex-141.md) standard, modeled after ERC-721, enables the creation of unique, non-fungible tokens. This standard is perfect for digital collectibles, gaming assets, or any application requiring distinct, non-interchangeable tokens. The implementation includes comprehensive metadata handling and transfer mechanics specifically optimized for the æternity blockchain.

## Implementation Examples

### DeFi Applications

The æternity ecosystem features several production-ready DeFi implementations that showcase the versatility of the AEX-9 standard:

**Reference Implementation**

The [`aeternity-fungible-token`](https://github.com/aeternity/aeternity-fungible-token) serves as the official reference implementation of the AEX-9 standard. This implementation provides developers with a solid foundation for creating their own fungible tokens, complete with best practices and security considerations.

**Token Sale and DEX**

* **Token Sale Example**: The [`aeternity-token-sale-example`](https://github.com/aeternity/aeternity-token-sale-example) demonstrates a straightforward implementation of a token sale contract, ideal for projects looking to launch their own tokens.
* **Superhero DEX**: The [`dex-contracts-v2`](https://github.com/aeternity/dex-contracts-v2) implements an Automated Market Maker (AMM) protocol, powering the Superhero DEX. This sophisticated implementation shows how to create complex DeFi applications using AEX-9 tokens.

**Social and Cross-Chain Solutions**

* **Tipping System**: The Superhero Social platform utilizes two key components:
  * [`tipping-contract`](https://github.com/aeternity/tipping-contract): Handles the core tipping functionality
  * [`tipping-oracle-service`](https://github.com/aeternity/tipping-oracle-service): Manages the oracle-based claim system for tips
* **Cross-Chain Trading**: The [`jelly-ae-htlc`](https://github.com/aeternity/jelly-ae-htlc) implements Hashed TimeLock Contracts (HTLC), enabling secure cross-chain token swaps through the JellySwap protocol.

### NFT Collection Examples

* [`aex141-nft-collection-example`](https://github.com/aeternity/aex141-nft-collection-example): A production-ready example implementation that demonstrates:
  * Collection creation and management
  * NFT minting processes
  * Transfer functionality
  * Metadata handling
  * Integration with front-end applications

### Additional Implementation Examples

* [`aex141-examples`](https://github.com/aeternity/aex141-examples): A comprehensive repository containing:
  * Multiple implementation patterns
  * Various use cases for different NFT types
  * Best practices for AEX-141 implementation
  * Extended functionality examples
  * Integration patterns with other æternity features

### Getting Started

To begin working with these token standards, developers can:

1. Review the standard specifications (AEX-9 or AEX-141)
2. Explore the reference implementations
3. Clone and modify the example repositories
4. Test implementations using the æternity SDK
5. Deploy to testnet for thorough testing before mainnet deployment

```sophia
// Example AEX-9 Token Interface
contract interface FungibleToken =
  record meta_info = {
    name : string,
    symbol : string,
    decimals : int }
    
  datatype event = 
    Transfer(address, address, int)
    | Allowance(address, address, int)
    
  entrypoint meta_info : () => meta_info
  entrypoint total_supply : () => int
  entrypoint balance : address => option(int)
  entrypoint transfer : (address, int) => unit
```

For detailed implementation guides, code examples, and best practices, please refer to the specific documentation sections for each standard and example project. You can also refer to the documentation for AEXs in general:

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td>AEXs Documentation</td><td><a href="/spaces/yxhRUAwn7tH8JUboTur7/pages/W9jokSJU3hT3ShxjgvwZ">/spaces/yxhRUAwn7tH8JUboTur7/pages/W9jokSJU3hT3ShxjgvwZ</a></td><td><a href="/files/Mn0raWPCGdVF9LgIRfVj">/files/Mn0raWPCGdVF9LgIRfVj</a></td></tr><tr><td>AEX-9</td><td><a href="/spaces/yxhRUAwn7tH8JUboTur7/pages/1RluVC5Z1xvUUxoXFoCX">/spaces/yxhRUAwn7tH8JUboTur7/pages/1RluVC5Z1xvUUxoXFoCX</a></td><td><a href="/files/vZyGDyzw08V42czk9Gxx">/files/vZyGDyzw08V42czk9Gxx</a></td></tr><tr><td>AEX-141 Non-Fungible Token</td><td><a href="/spaces/yxhRUAwn7tH8JUboTur7/pages/QFGf7Jv8oKZYNy3tIoLX">/spaces/yxhRUAwn7tH8JUboTur7/pages/QFGf7Jv8oKZYNy3tIoLX</a></td><td><a href="/files/60QmGVxDyAZeLFAtGHRM">/files/60QmGVxDyAZeLFAtGHRM</a></td></tr><tr><td>AEX 11 Fungible Token</td><td><a href="/spaces/yxhRUAwn7tH8JUboTur7/pages/q3snTC3g3R19wYhl7NLX">/spaces/yxhRUAwn7tH8JUboTur7/pages/q3snTC3g3R19wYhl7NLX</a></td><td><a href="/files/0NCGyNc4zbJxJv6fkjlQ">/files/0NCGyNc4zbJxJv6fkjlQ</a></td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aeternity.com/aeternity-developer-tools/token-standards.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
