This repository contains the source code for a Fungible Token (FT) built on top of the L1X SDK using the Rust programming language. This smart contract implements core functionalities similar to the ERC-20 standard on EVM networks, including balance management, token transfers, and an allowance delegation system.
- FT/ERC-20 Standard Compatibility: Supports core functions such as
transfer,transfer_from,approve, andallowancechecks. - Built-in Metadata Management: Stores comprehensive token information including Name, Symbol, Decimals (up to 18), and an optional icon URL.
- Authorized Minting Mechanism: The contract owner can add other addresses to the Authorized Callers list to mint new tokens in the future.
- Automated Transaction Safety: Utilizes Rust's safe arithmetic methods (
checked_add&checked_sub) to prevent overflow or underflow vulnerabilities.
The smart contract organizes its data into three main structures:
Stores the basic identity of the issued token:
name: Full name of the token (e.g., "Layer One X Coin").symbol: Token symbol/ticker (e.g., "L1X").decimals: Number of decimal places (maximum 18 decimals).icon: Optional external link for the token icon image.
The main state stored in the blockchain:
metadata: Token identity profile.balances: A key-value map (LookupMap) connecting addresses (Address) to their token balances (u128).allowances: A key-value map (LookupMap) managing token withdrawal quotas for third parties.total_supply: The total amount of tokens currently in circulation.authorized_callers: A set of addresses (BTreeSet) granted permission to mint new tokens.
pub fn new(metadata: FTMetadata, account_ids: Vec<Address>, amounts: Vec<U128>)This smart contract project is open-source and available under the MIT / Apache 2.0 license. You are free to copy, modify, and redistribute it for your DeFi project needs. Security Note: This function can only be called once by the contract owner during initial deployment. It sets the metadata and directly distributes the initial token supply to the targeted accounts.