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:
Token Metadata
FungibleStore,the storage location for a specific account's token balance:
FungibleAsset(FA), the memory representation of a fungible token in VM enviroment:
FungibleAsset's maximum_supply
and FungibleStore's amount
are all u128 type.
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:
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:
Withdraw
Deduct 1 EDS from Bob's account and create a corresponding FungibleAsset with an amount of 1 EDS.
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.
Deposit
Call the system function deposit to store the token in Alice's FungibleStore.
System Function Calls Related
Last updated