简体   繁体   中英

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

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 在此处输入图像描述

Please advise what I could do wrong here.

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

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

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

    在帐户详细信息中,单击“添加令牌”

  2. 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.

    查看数据,点击“下一步”,即可看到钱包中的代币余额。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM