1

In https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/ERC20/MintableToken.sol#L38, why is it necessary to emit the event

Transfer(0x0, _to, _amount);

after minting some coins? Can someone please explain this line of code? Are you actually transferring coins from 0x0 to the address _to?

5

That is not a transfer operations but an event notification.

This is done that way so block explorer and wallets that only interpret the 'Transfer' event can show the operation to the user. There were some complaint from users that the transfer failed because it didn't show up in their wallet (or block explorer).

Only the 'Transfer' event is part of the ERC20 standard, and the events 'Mint' and 'Burn' are not. It is a workaround around that limitation to generate a tranfer from 0x0 to simulate a 'Mint' event and, a transfer to 0x0 to simulate a 'Burn' event.

1

As the original author of this line of code, it is there to show EIP-20 transaction event in EtherScan. This way the token sale buyers can see that they received the tokens and the correct amount when they buy in to the token sale.

More discussion can be found in the orignal source code file:

https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol#L38

0

Transfer is just an event inherited from ERC20Basic.sol contract.

https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/ERC20/ERC20Basic.sol

What it's doing is just logging that the contract minted new coins and gave them to the address _to.

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.