BLTBY Token Contract

The BLTBY Token Contract is a critical component of the Built By DAO ecosystem, serving as the primary utility token within the platform. This ERC-20 token enables various functions such as transactions, staking, rewards, and redemption within the DAO. Designed to ensure a stable and controlled token economy, the BLTBY Token Contract integrates multiple mechanisms for secure minting, burning, and pausing operations. The total supply is fixed at 2.5 billion tokens, providing a robust base for value creation while maintaining scalability.

// BLTBY Token Contract : Built By DAO V 0.01.0
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

contract BLTBY Token ContractTokenContract is ERC20, Ownable, AccessControl, Pausable, ReentrancyGuard {
    uint256 public immutable MAX_SUPPLY = 2_500_000_000 * 10**18; // Total fixed supply of 2.5 billion tokens
    uint256 public constant MINT_CAP_PERCENTAGE = 5; // Up to 5% yearly inflation cap
    uint256 public constant INITIAL_SUPPLY = 100_000_000 * 10**18; // Initial circulation supply of 100 million tokens
    uint256 public lastMintTimestamp;
    
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public constant MULTISIG_ROLE = keccak256("MULTISIG_ROLE");

    // Event declarations
    event Minted(address indexed to, uint256 amount);
    event Burned(address indexed from, uint256 amount);

    // Custom errors for gas efficiency
    error UnauthorizedAccess();
    error MintingTooSoon();
    error MintExceedsCap(uint256 requested, uint256 allowed);
    error InsufficientRole(string role);
    error BurnFailed(address from, uint256 amount);
    
    constructor() ERC20("BLTBY Token Contract", "BLTBY") {
        _mint(msg.sender, INITIAL_SUPPLY); // Initial mint to deployer
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(MINTER_ROLE, msg.sender);
        _setupRole(MULTISIG_ROLE, msg.sender);
        lastMintTimestamp = block.timestamp;
    }

    /**
     * @dev Mint tokens, restricted to MINTER_ROLE with additional constraints.
     * Requires multi-signature approval via MULTISIG_ROLE.
     * @param to The address that will receive the minted tokens.
     * @param amount The amount of tokens to mint.
     */
    function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE) nonReentrant whenNotPaused {
        if (block.timestamp < lastMintTimestamp + 365 days) {
            revert MintingTooSoon();
        }
        if (totalSupply() + amount > MAX_SUPPLY) {
            revert MintExceedsCap(amount, MAX_SUPPLY - totalSupply());
        }
        if (amount > (MAX_SUPPLY * MINT_CAP_PERCENTAGE) / 100) {
            revert MintExceedsCap(amount, (MAX_SUPPLY * MINT_CAP_PERCENTAGE) / 100);
        }
        if (!hasRole(MULTISIG_ROLE, msg.sender)) {
            revert InsufficientRole("MULTISIG_ROLE");
        }
        
        _mint(to, amount);
        lastMintTimestamp = block.timestamp;
        emit Minted(to, amount);
    }

    /**
     * @dev Burn tokens, restricted to admin-controlled operations to stabilize value.
     * @param from The address from which tokens will be burned.
     * @param amount The amount of tokens to burn.
     */
    function burn(address from, uint256 amount) external onlyOwner nonReentrant whenNotPaused {
        if (balanceOf(from) < amount) {
            revert BurnFailed(from, amount);
        }
        _burn(from, amount);
        emit Burned(from, amount);
    }

    /**
     * @dev Pause all token transfers in case of emergency.
     */
    function pause() external onlyOwner {
        _pause();
    }

    /**
     * @dev Unpause token transfers.
     */
    function unpause() external onlyOwner {
        _unpause();
    }

    /**
     * @dev Transfer function with added checks for internal redemption mechanism.
     * @param recipient Address of the recipient.
     * @param amount Amount to be transferred.
     */
    function transfer(address recipient, uint256 amount) public override whenNotPaused returns (bool) {
        return super.transfer(recipient, amount);
    }

    /**
     * @dev Override transferFrom to ensure pausable functionality.
     * @param sender The address sending tokens.
     * @param recipient The address receiving tokens.
     * @param amount The amount of tokens to be transferred.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public override whenNotPaused returns (bool) {
        return super.transferFrom(sender, recipient, amount);
    }

    /**
     * @dev Redeem tokens at an internal redemption rate for services in the DAO.
     * This function would interact with other contracts managing the DAO's service provision.
     * @param amount The amount of tokens to redeem.
     */
    function redeem(uint256 amount) external nonReentrant whenNotPaused {
        if (balanceOf(msg.sender) < amount) {
            revert BurnFailed(msg.sender, amount);
        }
        _burn(msg.sender, amount);
        emit Burned(msg.sender, amount);
        // Further actions such as interacting with service contracts could be added here
    }
}

/*
 Key Features:
 - ERC-20 standard with 18 decimal places.
 - Initial supply: 100 million tokens, with a fixed max supply of 2.5 billion.
 - Minting controlled via MINTER_ROLE, with 5% yearly inflation cap and multi-sig approval.
 - Burn function for deflationary events and controlling token supply.
 - Internal redemption mechanism to allow tokens to be redeemed within the DAO ecosystem.
 - Initially admin-controlled, with pause and unpause mechanisms for security.
 - Custom errors for improved gas efficiency and clearer error handling.
 - Reentrancy guard applied to functions dealing with minting, burning, and redemption.
*/

Key Objectives and Features

The BLTBY Token Contract aims to create a secure, flexible, and scalable token economy for the DAO by focusing on:

  • Controlled Minting and Burning: Ensuring controlled supply adjustments to prevent inflation and maintain value.

  • Security and Stability: Incorporating features like Pausable and ReentrancyGuard to protect against vulnerabilities.

  • Governance and Role Management: Establishing clear, structured roles to govern token operations effectively.

Summary of Contract Flow

  • Role Assignment: The contract employs structured roles to manage minting, burning, and overall token governance securely.

  • Minting Tokens: Controlled minting through role-based restrictions, multi-signature approval, and annual cap limits to maintain a stable supply and avoid inflation.

  • Transferring and Redeeming Tokens: Allows members to transfer tokens and redeem them for services, integrating deflationary mechanics to manage supply.

  • Burning Tokens: Administrators can burn tokens to help stabilize value and align the supply with ecosystem needs, adding to the value proposition of the token.

  • Pausing Operations: Administrators can pause or resume the contract in emergencies, providing added security.

Key Features

1. Fixed and Initial Supply

  • Total Supply: 2.5 billion tokens are the fixed supply for BLTBY, ensuring no unchecked inflation. During the contract's deployment, an initial supply of 100 million tokens is minted to bootstrap ecosystem growth and operational needs.

  • Rationale: The initial mint acts as a foundational reserve to support development, early investors, and DAO operations.

2. Role-Based Access Control

  • Uses AccessControl to ensure operational integrity:

    • DEFAULT_ADMIN_ROLE: Assigned to deployer for overarching control.

    • MINTER_ROLE: Limits minting capabilities to trusted actors.

    • MULTISIG_ROLE: Requires multiple signatures for any minting to add additional security.

  • Role Management: Each role assignment is managed during the initial deployment, ensuring that token-related activities remain secure and authorized.

3. Minting and Inflation Control

  • Mint Cap: Minting is capped at 5% of the total supply per year, ensuring inflation control.

  • Time Restriction: Enforces a 365-day waiting period between mint operations to avoid excessive supply increase.

  • Multi-Signature Approval: Requires the MULTISIG_ROLE to sign off on minting activities, providing additional security.

4. Burning Tokens

  • Controlled Burning: Tokens can be burned by addresses with DEFAULT_ADMIN_ROLE, allowing the DAO to reduce supply to counteract inflation and provide token value stability.

  • Utility: Burning is also used for token redemption, enhancing token value by providing ecosystem-based services.

5. Pausable Mechanism for Security

  • Pausable Functions: The pause() and unpause() functions allow for temporary suspension of token transfers, ensuring system stability in emergencies or during critical upgrades.

  • Owner Access: Only the owner can initiate or lift pauses, adding a control mechanism against unauthorized token movement.

6. Transfer and Redemption Mechanisms

  • Standard ERC-20 Transfers: Includes transfer() and transferFrom() functions, with added restrictions that these operations are only valid when the contract is unpaused.

  • Redemption Function: The redeem() function allows members to exchange BLTBY tokens for services within the DAO, burning tokens to provide a deflationary element that strengthens the token’s value.

7. Reentrancy Protection

  • ReentrancyGuard is applied to key functions like mint, burn, and redeem. This prevents reentrancy attacks where malicious actors might try to manipulate the contract by exploiting its execution flow.

8. Custom Errors for Gas Efficiency

  • Custom errors like UnauthorizedAccess(), MintingTooSoon(), and MintExceedsCap() are implemented to handle edge cases more efficiently.

  • Gas Efficiency: Custom errors consume less gas than standard require() statements, reducing operational costs and improving the efficiency of error handling.

Summary

The BLTBY Token Contract is designed to be the cornerstone of the Built By DAO ecosystem, allowing for controlled minting, safe burning, and secure transactions. It incorporates advanced features like role-based access control, custom errors, reentrancy protection, and pausable functionality, ensuring that token operations are secure and efficient. By adhering to best practices in role assignment, minting, and managing token transactions, the BLTBY Token Contract provides a robust, scalable, and adaptable foundation for the DAO's economic needs.

The contract flow includes role assignment, minting, transfers, redemption, and burning to maintain stability and ensure the value of the token. This contract will evolve over time, with the potential for future upgrades that integrate DAO-level governance, adding even more transparency and community involvement in managing the token supply.

Last updated

Logo

© Built By DAO Holdings LLC