From d7c584d726b2d9e4ef55a6ff6d614f9cade36bfb Mon Sep 17 00:00:00 2001 From: Shyngys Shynbolatov Date: Tue, 27 Jul 2021 22:27:36 +0600 Subject: [PATCH] max supply function added --- trc20token.sol | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/trc20token.sol b/trc20token.sol index e4d5f56..60d32d3 100644 --- a/trc20token.sol +++ b/trc20token.sol @@ -1,12 +1,13 @@ pragma solidity ^0.5.0; -contract CraftStakeToken { +contract JDoge { string public name; // token name string public symbol; // token symbol uint8 public decimals; uint256 public totalSupply; address public owner; + uint256 constant public maxSupply = 1000000*10**uint256(decimals); mapping (address => uint256) public balanceOf; mapping (address => mapping (address=> uint256)) public allowance; @@ -22,8 +23,8 @@ contract CraftStakeToken { totalSupply = 1000000*10**uint256(decimals); owner = msg.sender; balanceOf[owner] = totalSupply; - name = "CraftStake"; - symbol = "CRS"; + name = "JDoge"; + symbol = "JDG"; } function _transfer(address _from, address _to, uint256 _value) internal { @@ -93,6 +94,7 @@ contract CraftStakeToken { // generate new tokens (only owner can do it) function mint(uint256 _value) public returns (bool success) { require(msg.sender == owner); + require(totalSupply + _value <= maxSupply); balanceOf[owner] += _value; totalSupply += _value; @@ -106,6 +108,7 @@ contract CraftStakeToken { function mintTo(address _to, uint256 _value) public returns (bool success) { require(msg.sender == owner); require(_to != address(0)); + require(totalSupply + _value <= maxSupply); balanceOf[_to] += _value; totalSupply += _value;