A lot of services interact with ERC20 tokens (exchanges, DApps, etc.). The problem is that one cannot simply verify that some token is an ERC20 token. This can be done only by ordering an audit or writing and running a bunch of tests. However, these options are expensive and not scalable. In this article, I present SmartDec ERC20 Test Suite — a decentralized way to check ERC20 compliance with an on-chain proof.

Audit or tests

First, let us discuss the disadvantages of a manual audit or custom tests.

Manual audit. First, it is expensive. Second, it still does not solve the problem for smart contracts. One can not see the results on-chain. Of course, all the auditors of the world can agree and make the on-chain registry for ERC20 tokens audited. However, the quality of each audit still will not be proven.

Tests development. You have to pay for tests, too. If these are developers of smart contracts, then each of them writes his own tests. Which may not cover all the subtleties of the ERC20 standard. For example, according to the standard:

A token contract which creates new tokens SHOULD trigger a Transfer event with the _from address set to 0x0 when tokens are created.

At the same time, it is not necessary to create a special event when burning (destroying) tokens. Moreover, tests also do not solve on-chain token verification problem.

What do we need?

So let us create tests for the ERC20 standard, with which anyone can easily check the token for compliance. Why not make a service that can benefit not only the developer but any potential user of the token.

Here is what we want from such service:

low price

full automation

easy result check: any user can verify the results of the standard check

easy use: any user of the token can check the standard compliance, not only a developer

results available on-chain

on-chain proof of the fact that the checks were actually run and passed

ideally, everything should be trustless

What are the options?

Create a pack of tests for truffle. If tests are written, then indeed, the check will be free and fast for developers and exchanges. One just needs to download the token code and run a series of tests. However, not every user of tokens knows the word truffle. Besides, results will not be visible on-chain. In addition, there is a number of subtle points: what to do if the token code is unverified on etherscan, tests need to be supported since the library versions change, and so on.

Centralized service. We can create a service that receives the address of the token, a fee, runs all checks and reports the result. Now it is not only cheap to use, but also convenient: any user can specify the address of the token and pay money. However, the results are still not recorded on-chain. Of course, we can create a smart contract, in which the fact whether the token meets the stated standard will be recorded. However, this scheme requires trust: one needs to trust the service.

So why not run all tests on mainnet? Yes, we will need to pay for gas, but all the tests and their results will be visible in the form of on-chain transactions. Anyone will be able to see which checks have been run.

SmartDec ERC20 Test Suite

SmartDec ERC20 Test Suite is a service that accepts payment to a smart contract and runs a series of tests for ERC20 standard compliance in the form of on-chain transactions. The final test results are recorded in a smart contract. Thus, any person or exchange can easily launch a check using the website. If one does not trust the website, then one can run tests directly through a smart contract. Test Suite cannot fake the test results as each test is a transaction recorded in the blockchain. Thus we achieved:

low price

easy start and validation

full automation

all results are available on-chain; thus, smart contracts that interact with ERC20 tokens can verify standard compliance by looking in the registry

SmartDec ERC20 Test Suite is available here.