Solidity and Blockchain – Why Event Not Visible on Etherscan Transaction List

blockchainethergo-ethereumsolidity

I have a BuyToken event when user send ether to smart contract they will receive tokens based on ether amount. For ex: 1 ETH = 1000 Token.

/// This notifies clients about the Buy Token
event BuyToken(address user, uint256 eth, uint256 token);

There is my buy() function

 /**
*  function for Buy Token
*/

function buy() payable public returns (uint amount){
      require(msg.value > 0);

      amount = ((msg.value.mul(TokenPerETHBuy)).mul( 10 ** uint256(decimals))).div(1 ether);
      balanceOf[this] -= amount;                        // adds the amount to owner's 
      balanceOf[msg.sender] += amount; 
      emit BuyToken(msg.sender,msg.value,amount);
      return amount;
}

It works well when user send ether user will receive tokens.

But this transaction event is not visible on Etherscan.io

For ex:
Ropsten link

I send 0.2 ether I receive 200 tokens. I can see ether transaction. But received tokens transaction not visible on "ERrc20 Token Txns" tab.

Pelase can you help ??

Best Answer

You have to emit the Transfer event for Etherscan to see it as a token transfer . Most people handle this by logging 0x0 as the from address.

Related Topic