Working on a simple test token that I'm going to use to support a DApp project. Key functions I have questions regarding are as follows:

constructor() {
        name = "Test Token";
        symbol = "TTKN";
        decimals = 18;
        _totalSupply = 1000000000000000000000000000000;
        //WITHOUT DECIMALS = 1,000,000,000,000; should be 1 trillion

        balances[msg.sender] = _totalSupply;
        emit Transfer(address(0), msg.sender, _totalSupply);

function totalSupply() public override view returns (uint256) {
    return _totalSupply  - balances[address(0)];
  1. First, a quick question about decimals and supply: did I set this up correctly to create 1 trillion of the TTKN token? And do I really need so many decimal places?

  2. Second, what exactly is address(0)? My understanding of the constructor is that address(0) first transfers all the tokens to msg.sender, which is me, the person who deploys this contract.

  3. And finally, what are the best practices for initially distributing the tokens? What I want is basically as follows:

a) Myself and a few other devs each get 1% of the initial supply

b) Our DApp, a separate smart contract, will get 50% of the initial supply, and will use this to reward users for interacting with our website/project

c) To accomplish a) and b), me, the contract deployer, should manually transfer these tokens as planned?

d) The rest of the coins... available to go on an exchange somehow (maybe out of scope of question)

So now that I've deployed this test token on remix.ethereum.org and am getting a feel for how to transfer around the tokens, I want to understand the above points in relation to our project. Is my plan generally acceptable and feasible, and is it the case that as the initial owner I'm just making a bunch of transfer calls on the ETH mainnet eventually when I deploy?


  • 1
    1. looks okay you should deploy that on a testnet and then import you token in metamask or wallets which show you the balance without decimal / 2. address 0 is non-reachable blackhole address and it is used usually metaphorically to mint tokens / 3. no one will answer that but transferring tokens over and over will cost you toooooooooooooo much money on fees, more than what u can afford :) there are other ways to distribute tokens like vesting or claiming or merkle airdrop contracts
    – Majd TL
    Dec 1 '21 at 20:39
  • 1
    I don’t know if what you do with totalsupply function ist correct and erc20 compatible, check that again
    – Majd TL
    Dec 1 '21 at 20:40
  • @MajdTL thanks for the comments! Regarding totalsupply function, this was copied from boilerplate code, so I assume it's correct. It seems to work for testing. My understanding then, is that it's the total initial supply value minus any "blackhole" (burned?) tokens.
    – JDS
    Dec 1 '21 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.