0

When writing ERC20 token, could I use a different event name? Or must I use Transfer as the token transfer event name?

1

You must use not only the exact event names (Transfer, Approve) but the exact canonical event signature if you want to comply with the standard.

Not only that, you must use the exact three functions (transfer, transferFrom, and approve) by name with the exact function signatures as well.

Otherwise, any tool that purports to support the ERC 20 standard (such as Etherscan) won't know what to do with your token. This is the exact reason why it's a standard--so tools that know nothing else about your ERC 20 token know how to deal with it.

Here's the actual page defining the standard. Pay particular attention to the MUST's, SHOULD's etc. They have precise meanings. You can see here that the Transfer event is a MUST.

| improve this answer | |
0

You can use any event name of your choice. You need to declare it before use like:

event Transfer(address indexed from, address indexed to, uint256 value);

You can choose the event name of your choice. For eg,

event TokenTransfer(address indexed from, address indexed to, uint256 value);

Now in transfer you will emit the TokenTransfer event instead of Transfer event. And while listing to events your client must be aware about the name of event.

What's the need for changing for changing event name? Using Transfer event for transfer function is just a standard which you may or may not follow, but ideally, you should follow.

For instance, if I want to develop a wallet or any client supporting your currency and I know this is erc-20 token, so I will expect that the code will have a Transfer event which I can listen to. But this is just my openion else you can go by your choice of event name.

| improve this answer | |
  • Thanks. I asked the question because I wrote a contract with a different event name, but seems etherscan.io will not recognise my event whenever I transfer tokens around. Etherscan will not show Token Transfers tab under my address. Is that due to the different name? – Louis Nov 8 '17 at 6:52
  • @Louis You need two thing for tokens to be recognized as such in Etherscan, the contract code should be verified, and generate events following EIP-20 specification. – Ismael Nov 8 '17 at 19:23
  • @Ismael Which means I should use exactly the same function names and event names, right? Thanks for your comment. – Louis Nov 9 '17 at 1:31

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.