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