Transaction is visible on Ethereum blockchain explorer, but token is not displayed in Metamask wallet

Viewed 1931

I am playing with Ethereum smart contracts and noticed some strange behavior of some transactions. Transaction is visible and it states that tokens are sent to an address but when I check balance on Metamask it's not here (Token contract is added to MetaMask). What could be the reason of such contract behavior?

This is example transaction: https://ropsten.etherscan.io/tx/0xf3316c497fd47ee79be57be7b91cb96cc0414003a155d8ff8bc83b3a090594c9 200,000 tokens is sent to https://ropsten.etherscan.io/address/0x9DEF8C013eb590aFf09c8c76F9A74A3055fAA177#tokentxns and it's displayed on ropsten network explorer, but I can't see them or manipulate on MetaMask.

This is part of my smart contract which does transfer, I marked line with comment "invisible" which does not work for me:

function transfer(address to, uint256 value) public returns (bool) {
  require(value <= _balances[msg.sender]);
  require(to != address(0));

  uint256 tokensToBurn = findOnePercent(value);
  uint256 tokensToStack = findOnePercent(value);
  uint256 tokenstoDeduct = tokensToBurn.add(tokensToStack);
  uint256 tokensToTransfer = value.sub(tokenstoDeduct);

  _balances[msg.sender] = _balances[msg.sender].sub(value);
  _balances[to] = _balances[to].add(tokensToTransfer);

  _totalSupply = _totalSupply.sub(tokenstoDeduct);

  emit Transfer(msg.sender, to, tokensToTransfer); // visible on metaMask
  emit Transfer(msg.sender, address(0), tokensToBurn); // burned
  emit Transfer(msg.sender, address(VAULT_ADDRESS), tokensToStack); // invisible on metaMask
  return true;
}

This is screenshot of address wallet: 0x9DEF8C013eb590aFf09c8c76F9A74A3055fAA177 enter image description here

Please advise what I could do wrong here.

[meanwhile I submitted ticket to MetaMask, maybe it's a defect on wallet extension]

1 Answers

You need to add the contract address to your Metamask instance.

  1. In the account detail, click on "Add token"

    In the account detail, click on "Add token"

  2. Paste the conctract address to the address field in the "Custom token" tab

    Paste the conctract address to the address field in the "Custom token" tab

  3. Review the data, click "Next", and you you can see the token balance in your wallet.

    Review the data, click "Next", and you you can see the token balance in your wallet.

Related