每天增加 TRC20 代币的总供应量

increase total supply of TRC20 token daily

我想在 Tron 区块链上发行一个令牌,我从下面的地址得到了它的模板: https://github.com/TRON-Developer-Hub/TRC20-Contract-Template

问题是我想将我的代币设置为每天自动铸造指定数量的代币。 (例如每天铸造 2000 个代币)

我应该在模板中添加什么?

你可以添加一个功能,下面这样。 但是你必须手动执行 mint Daily()

    uint256 constant private dailyMinted = 2000e18;
    uint256 lastMintTime;

    address public _owner;
    
    constructor(
        string memory name,
        string memory symbol,
        uint8 decimals,
        address owner
    ) public {
        _name = name;
        _symbol = symbol;
        _decimals = decimals;

        _owner = owner;
        lastMintTime = block.timestamp;
    }
    
    function mintDaily() public {
        require(_owner == msg.sender, "not permitted");
        // 24h = 86400
        require(lastMintTime + 86400 >= block.timestamp, "mint already" );
        _mint(msg.sender, dailyMinted);
        lastMintTime = block.timestamp;
    }