[Ethereum] Total supply of ERC-20 TOKEN

erc-20tokens

I am creating new ERC-20 DOTAToken. I want my token to have total supply 800 millions and 18 decimals. Is it correct way to declare it?

contract DOTAToken {
  string constant public name = "DOTATOKEN";
  string constant public symbol = "DTK";
  uint256 constant public decimals = 18;
  uint256 constant public totalSupply = 8 * 10 ** (8 + 18);

  function DOTAToken () public {
    owner = msg.sender;
  }
}

Best Answer

Basically correct, but you need to set initial balance for owner also and from the beginning, the balance of owner equal to total supply. Total supply is nothing if you dont handle the token balance for each account/address in your smart contract.

for more detail, you can refer to openzeppelin template code

https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC20/StandardToken.sol

Related Topic