# Endless Coin(EDS)

On the Endless chain, all types of tokens adhere to the FungibleAsset(FA) standard. This concept is equivalent to "fungible tokens" on other blockchains, such as Ethereum. For simplicity, in the following sections, "token" and "asset" are used interchangeably.

## Digital Assets

In simple terms, every token corresponds to:

1. Token Metadata

```rust
struct Metadata has key {
    /// Token name, e.g., "US Dollar Tether"
    name: String,
    /// More commonly used token symbol, e.g., "USDT"
    symbol: String,
    /// Token precision, e.g., EDS or Ether
    decimals: u8,
    /// Token icon URI
    icon_uri: String,
    /// Project URI
    project_uri: String,
}
```

2. FungibleStore，the storage location for a specific account's token balance:

```rust
struct FungibleStore has key {
    /// Address of the metadata object
    metadata: Object<Metadata>,
    /// Token balance
    balance: Aggregator<u128>,
    /// Freeze option
    frozen: bool,
}
```

3. FungibleAsset(FA), the memory representation of a fungible token in VM enviroment:

```rust
struct FungibleAsset {
    // Associated token metadata
    metadata: Object<Metadata>,
    // Token amount
    amount: u128,
}
```

{% hint style="warning" %}
FungibleAsset's `maximum_supply` and FungibleStore's `amount` are all **u128** type.
{% endhint %}

FungibleAsset only exists in VM memory; at the end of transaction, any FA needs be merged into `FungibleStore` of corrsponding Account, otherwise FA is burned or dropped.

Endless provides move functions to handle token operations, such as:

* `public entry fun transfer<T: key>(sender: & signer, from: Object<T>, to: Object<T>, amount: u128)`
* `public fun withdraw<T: key>(owner: & signer, store: Object<T>, amount: u64): FungibleAsset`
* `public fun deposit<T: key>(store: Object<T>, fa: FungibleAsset)`
* `public fun mint_to<T: key>( ref: & MintRef, store: Object<T>, amount: u128)`
* `public fun burn_from<T: key>( ref: & BurnRef, store: Object<T>, amount: u128)`
* ...

These functions enable token minting, transferring, and burning between accounts.

## EDS Native Token

The metadata for the native token EDS is as follows:

```json
name: string::utf8(b"Endless Coin"),
symbol: string::utf8(EDS_SYMBOL)
decimals: 8,
icon_uri: "https://www.endless.link/eds-icon.svg"
project_uri: "https://www.endless.link"
```

The smallest denomination of EDS is **Vein**; 1 EDS is equivalent to $$1 \times 10^{8}$$ veins.

Assume Alice has an account on the Endless Chain but does not currently hold any EDS tokens.

If Bob transfers 1 EDS to Alice, the transaction will involve the following steps:

{% stepper %}
{% step %}
**Withdraw**

Deduct 1 EDS from Bob's account and create a corresponding FungibleAsset with an amount of 1 EDS.
{% endstep %}

{% step %}
**CreateFungibleStore**

Check if Alice's account has an associated storage location for FungibleStore. If not, create a new storage location and link it to Alice's account.
{% endstep %}

{% step %}
**Deposit**

Call the system function deposit to store the token in Alice's FungibleStore.
{% endstep %}
{% endstepper %}

## System Function Calls Related

For more details on system functions related to EDS, refer to the [source code](https://github.com/endless-labs/endless-move-framework/tree/main/endless-framework/sources/endless_coin.move)
