r/ethereum•
Dexaran

Reminder about problems of most ERC20 tokens.

Every token developer should pay attention! Developing a token that will lead to monetary losses for your users is not a good solution. Please be responsible for the developments that you are conducting.

Saying "Not a bug, human error" is not good practice, if this is leading to the loss of hundreds of thousands of USD.

This is a description of issues of ERC20 token standard, which is used for almost all Ethereum ICOs. Every ERC20 token is affected.

ERC20 tokens have two critical issues that are already causing money losses. They are:

1. Lack of transaction handling.

There is two ways of performing a transaction in ERC20 tokens:

  1. transfer function.

  2. approve + transferFrom mechanism.

Approve + transferFrom mechanism must be considered deprecated now. It was only relevant before EIP150.

Token balance is just a variable inside token contract.

Transaction of a token is a change in the internal variables of the contract (the balance of the sender will be decreased and the balance of the recipient will be increased).

The transfer function will not notify the recipient that transaction occur. The recipient will not be able to recognize the incoming transaction! I wrote this illustration of the process that is leading to unhandled transactions and money losses.

As a result, if the recipient is a contract, users must transfer their tokens using the approve + transferFrom mechanism, and if the recipient is an externally owned account address, users must transfer their tokens via the transfer function. If a user will make a mistake and choose a wrong function then the token will get stuck inside contract (contract will not recognize a transaction). There will be no way to extract stuck tokens.

At least $400 000 are already lost because of this mistakes.

2. approve + transferFrom mechanism is potentially insecure. Re-approval attack.

approve + transferFrom mechanism allows double spents.

This is not relevant unless there will be a possibility to create custom token-exchanges like Bancor token changer.

A possible attack is described here.

The solution. ERC223 token standard.

The ERC #223 token standard was specially developed to solve issues of the ERC #20 token standard.

The most technically advanced developers who understand the problem already use the new token standard.

Fortunately, Bittrex exchange has restandardized its deposit contracts to be ERC223 compliant. (Source)

My previous articles about the problem.

article #1

article #2

article #3

article #4

article #5

article #6

article #7

Posted Aug 17, 2017, 7:55 PM UTC · edited

3936
Loading comments…