// File: ConvertLib.sol



// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

// A library is like a contract with reusable code, which can be called by other contracts.
// Deploying common code can reduce gas costs.
library ConvertLib{
	function convert(uint amount, uint conversionRate) public pure returns (uint convertedAmount)
	{
		return amount * conversionRate;
	}
}

// File: RoboMusk.sol



// SPDX-License-Identifier: MIT
/**
   * @title RoboMusk
   * @dev RoboMusk Contract
   * @custom:dev-run-script scripts/deploy_with_ethers.ts
*/
contract ContractName {}

pragma solidity ^0.8.17;

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

contract RoboMusk is IERC20 {
    string public name = "RoboMusk";
    string public symbol = "RBM";
    uint8 public decimals = 18;
    
    uint256 private constant MAX_SUPPLY = 1_000_000_000 * 10** uint256(18); // 1 billion tokens
    uint256 private constant BURN_RATE = 2; // 2% burn rate per transaction
    
    mapping(address => uint256) private balances;
    mapping(address => mapping(address => uint256)) private allowances;
    
    uint256 private totalTokens;
    address private owner;
    
    constructor() {
        owner = msg.sender;
        totalTokens = MAX_SUPPLY;
        balances[owner] = totalTokens;
    }

    function totalSupply() external view override returns (uint256) {
        return totalTokens;
    }

    function _mint(address account, uint256 amount) public onlyOwner {
        _mint(account, amount);
    }

    modifier onlyOwner() {
        require(msg.sender == owner, "Only the contract owner can call this function.");
        _;
    }
    
    
    function balanceOf(address account) external view override returns (uint256) {
        return balances[account];
    }
    
    function transfer(address recipient, uint256 amount) external override returns (bool) {
        _transfer(msg.sender, recipient, amount);
        return true;
    }
    
    function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, msg.sender, allowances[sender][msg.sender] - amount);
        return true;
    }
    
    function approve(address spender, uint256 amount) external override returns (bool) {
        _approve(msg.sender, spender, amount);
        return true;
    }
    
    function allowance(address owner_a, address spender) external view override returns (uint256) {
        return allowances[owner_a][spender];
    }
    
    function _transfer(address sender, address recipient, uint256 amount) internal {
        require(sender != address(0), "Transfer from the zero address");
        require(recipient != address(0), "Transfer to the zero address");
        require(amount > 0, "Transfer amount must be greater than zero");
        require(balances[sender] >= amount, "Insufficient balance");
        
        uint256 burnAmount = amount * BURN_RATE / 100; // Calculate the burn amount based on the burn rate
        uint256 transferAmount = amount - burnAmount;
        
        balances[sender] -= amount;
        balances[recipient] += transferAmount;
        totalTokens -= burnAmount;
        
        emit Transfer(sender, recipient, transferAmount);
        emit Transfer(sender, address(0), burnAmount);
    }
    
    function _approve(address owner_a, address spender, uint256 amount) internal {
        require(owner_a != address(0), "Approve from the zero address");
        require(spender != address(0), "Approve to the zero address");
        
        allowances[owner_a][spender] = amount;
        emit Approval(owner_a, spender, amount);
    }
}