Recently, I've created a token and it is pure ERC-20 Compliant...I've sent some token to another address but when I see it on rinkeby testnet etherscan web page it shows 0 holder despite having the transaction in transaction section below...Moreover, when I try to view token in metamask, Metamask also showed, we had trouble loading your token balance...What I'm missing here ??

Here's my code:

contract myToken {
  address payable owner;
  string public name = "Test TOKEN";
  string public symbol = "TT";
  uint public totalSupply_;
  uint public tokenSold;
  uint8 public decimals = 0;
  uint256 public token_price = 300000000000000;
  uint256 public token_incremental_price = 0;
  uint256 public currentPrice;

  event Transfer(address indexed _from, address indexed _to, uint tokens);
  event Approval(address indexed _tokenOwner, address indexed _spender, uint tokens);

  constructor(uint initialSupply) public  {
    owner = msg.sender;
    totalSupply_ = initialSupply * 10**uint256(decimals);
    totalSupply_ = initialSupply;
    tokenLedger[owner] = totalSupply_;
    currentPrice = token_price + token_incremental_price;

mapping(address => uint) internal tokenLedger;
mapping(address => mapping(address => uint256)) public allowed;

function myTokens() public view returns(uint256) {
    return balanceOf(msg.sender);

function balanceOf(address _customerAddress) public
    return tokenLedger[_customerAddress];

function totalSupply() public view returns (uint256) {
      return totalSupply_;

 function transfer(address _toAddress, uint256 _amountOfTokens)
    returns(bool success)
    address _customerAddress = msg.sender;
    require(_amountOfTokens <= tokenLedger[_customerAddress] && _amountOfTokens > 0);

    tokenLedger[_customerAddress] = SafeMath.sub(tokenLedger[_customerAddress], _amountOfTokens);
    tokenLedger[_toAddress] = SafeMath.add(tokenLedger[_toAddress], _amountOfTokens);
    emit Transfer(_customerAddress, _toAddress, _amountOfTokens);
    return true;

function transferFrom(address _from, address _to, uint256 tokens) public returns(bool success)  {
    require(tokens <= tokenLedger[_from]);
    require(tokens > 0);
    require(tokens <= allowed[_from][msg.sender]);        
    tokenLedger[_from] = SafeMath.sub(tokenLedger[_from], tokens);
    tokenLedger[_to] = SafeMath.add(tokenLedger[_to], tokens);
    allowed[_from][msg.sender] = SafeMath.sub(allowed[_from][msg.sender], tokens);
    emit Transfer(_from, _to, tokens);
    return true;

function approve(address _spender, uint256 _tokens) public returns(bool success) {
    allowed[msg.sender][_spender] = _tokens;
    emit Approval(msg.sender, _spender, _tokens);
    return true;

function allowance(address _owner, address _spender) public view returns(uint256 remaining) 
    return allowed[_owner][_spender];
  • What's the token address? Did you register the source code on etherscan? On etherscan testnet aren't updated quickly, so perhaps after some hours it will appear as a token. – Ismael Nov 16 '20 at 16:42

There are various problems with your code:

  1. It doesn't compile. Related to at least the } on about line 10 which closes the contract too soon

  2. It's not ERC20 compliant. The contract is missing at least function transferFrom (it's named wrong in your code)

  3. It's missing the event signatures.

  • on line 10, it was a typo.. One point, I forgot to mention is I'm purchasing and selling token through DAPP..Transactions are showing in the etherscan but the token holder remain 0.. – Yash Nov 16 '20 at 11:14
  • I have reconfigured the code..it had events and the contract was closed by typo in the stack exchange.. – Yash Nov 16 '20 at 11:17

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.