L Token#
Overview#
L Token is a token contract based on an upgraded ERC20 standard, implementing the following core functionalities:
Token Minting and Burning: Control minting and burning through role-based permissions
User Claim Mechanism: Supports users claiming tokens through whitelist and receiving ERB rewards
Maximum Supply Limit: Total supply cannot exceed 1 trillion tokens
Permission Control: Role-based access control (inherited from Auth contract)
Core Constants and Variables#
Maximum Supply#
uint256 public constant MAX_SUPPLY = 100000000000 * 10 ** 18; // 1 trillion tokens (18 decimals)
Error Definitions#
error InvalidZeroAddress(); // Invalid zero address
error CallerIsZeroAddress(); // Caller is zero address
error InvalidErbAmt(uint256 erbAmt); // Invalid ERB amount (msg.value is negative)
error ExceedsMaxSupply(uint256 totalSupply, uint256 lAmt); // Total supply exceeds maximum
error InsufficientERBBalance(address from, uint256 balance); // Insufficient ERB balance in contract
Core Events#
event Claim(
address indexed recipient, // Recipient address
uint256 lAmt, // Amount of L tokens claimed
uint256 erbAmt // Amount of ERB transferred (msg.value)
);
Core Function Details#
1. Initialization Function#
function initialize(address superOwner) public initializer {
super.initializeAuth(superOwner); // Initialize Auth contract's super admin
__ERC20_init("L", "L"); // Initialize ERC20 token name and symbol
}
Requires super admin address
Initializes ERC20 token parameters
2. Whitelist Modifier#
modifier onlyWhitelisted() {
require(hasRole(WHITELISTED_ROLE, msg.sender), "Not whitelisted");
_;
}
Only allows addresses with WHITELISTED_ROLE to call protected functions
3. Minting Function#
function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {
_mint(to, amount);
}
Requires MINTER_ROLE
No supply limit check (may bypass MAX_SUPPLY)
4. Burning Function#
function burn(address from, uint256 amount) public onlyRole(BURNER_ROLE) {
_burn(from, amount);
}
Requires BURNER_ROLE
5. User Claim Function#
Must be called through whitelist
- Key Logic:
Check if msg.value is valid (but msg.value is unsigned integer, this check is redundant)
Ensure contract has sufficient ERB balance for transfer
Prevent zero address calls or receipts
Ensure total supply doesn’t exceed MAX_SUPPLY
Mint tokens and transfer user’s paid ERB