ERC20 for beginners

On the beginning of August, 2019 TrustNodes published that Ethereum have crossed the 200,000 smart contracts bar deployed on their blockchain,

Most of the smart contracts deployed are ERC20 tokens and I thought it would be interesting to learn more about those.

At the time that I write this article (23 September 2019), there are 214,692 ERC20 ( Tracker: smart contracts on the Ethereum blockchain.

ERC20 is a claim, a story – not a proof! In a blatant approach, I would call it a lie.

ERC20 is a standard written for tokens on the Ethereum blockchain. But, we need to know that no one checks the code of those tokens. So it might be that the code is correct and it does the things that we refer as ERC20, but, it might be that the code is not correct and that it does different things.

In this article we will learn how to look on different ERC20 tokens and learn on their solidity program (smart contract).

The ERC20 standard means that the token has, at least, the following functions:

totalSupply(), balanceOf(address _owner), transfer(address _to, uint256 _value), transferFrom(address _from, address _to, uint256 _value), approve(address _spender, uint256 _value), allowance(address _owner, address _spender).

Before we dive in, let me make several remarks:

  1. Solidity is a very good programing language. It is pretty simple to understand. In this article I will walk you through easy tools to understand the ERC20 token activity and to be able to decide if it suits your investment rules.

  2. is the place to explore the Ethereum blockchain.

  3. I will follow two ERC20 tokens, during this article: 1UP the Uptrennd token and A-Token ( which is the token that I have developed.

  4. In my culture the saying goes (my translation): "The strict man (or woman) cannot teach and the shy man (or woman) cannot learn" – feel free to ask, to investigate and to learn more.

Let us move a little further:

This is a sort of a bank ledger:

Account number

Balance in US$












Any ERC20 token is primarily a list of Ethereum accounts that have some balance of this token. Very similar to the above bank ledger.

When you open (in another window) and search for Uptrennd, you get a list of 1Ups tokens. The needed one is the one with the site connected to it.

When we open the 1UP token we can go to the "Holders" section:

(Please do open this link and see the resembles to the bank ledger)

Searching "A-Token(A)" will connect you to the A-Token. The "Holders" list is here:


An account ledger in the bank - describes the activity within an account:

Account number 10001:










































Each account has IN/OUT activities that make the current balance. The same goes with each token.

For example this account for the A-Token:

Or this account for the 1UP:

That means that the fundamental functions needed to be programmed are the IN/OUT activities.

In order for us to check the solidity code of an ERC20 token we need to look for the green v check in the contract section of the smart contract on the site.

is the link for the 1UP token and, it has the green v check that proves the code is an "exact match".

For the A-Token:

and, of course, it has the green v that proves that the code is an "exact match".

Never work with any token that you cannot check its smart contract!

The fundamental activities (IN/OUT) can be covered with those functions that are a must in an ERC20 token:

  1. Transfer by the account owner.

  2. Approve that someone else is allowed to make a transfer.

  3. Then use this approved value with the transferFrom function.

The rest of the ERC20 functions are tools to get information from the smart contract.

So now, we will make a comparison of the ERC20 as written on both tokens. If they are doing the "right" activity then those are correct ERC20 tokens.

transfer(address _to, uint256 _value):

1UP code:

function transfer(address _to, uint256 _value) public returns (bool success) {

        require(balances[msg.sender] >= _value);

        balances[msg.sender] -= _value;

        balances[_to] = _value;

        emit Transfer(msg.sender, _to, _value);

        return true;


A-Token code:

function transfer(address _to, uint256 _amount) external returns(bool success) {

                                require(_amount > 0);

                                require(_amount <= balances[msg.sender]);

                                require (_to != address(0));

                                balances[msg.sender] = balances[msg.sender].sub(_amount);

                                balances[_to] = balances[_to].add(_amount);

                                if(tokenHoldersMap[_to] != true) {


                                                tokenHoldersMap[_to] = true;


                                emit Transfer(msg.sender, _to, _amount);

                                return true;


What is the goal of a transfer function? The function is moving tokens from the sender account to another (accepting) account. This is what we want that such a function will do:

  1. Check that the sender has enough tokens to send. Written in the 1UP:         require(balances[msg.sender] >= _value); written in the A-Token:                      require(_amount <= balances[msg.sender]);

  2. Subtract the proper value (amount) from sender account. Written in !UP: balances[msg.sender] -= _value; Written in A-Token:                     balances[msg.sender] = balances[msg.sender].sub(_amount);

  3. Add the proper value (amount) to the receiving account. Written in 1UP:         balances[_to] = _value; Written in A-Token:                                                     balances[_to] = balances[_to].add(_amount);


That's that!

 We can see that both functions do what is expected of them. Although written slightly different from each other, both function are ERC20 in their execution – moving tokens from sender account to the other (accepting) account.

(The A-Token code for this function adds new accounts to another list (database) that will be used on its' split function. The split function will multiply each account balance thus lowering the price of each A-Token. Same as shares splitting).

The following code:  balances[to] = _value; will not be an ERC20! Because it will not add the value to the right account. It is a tiny change in the code. And wallets and smart contracts can approach this function as an ERC20. But, and it is a big but – this is not an ERC20 function.

What we see here is that it is a must to check the claims that the token is an ERC20 one!

The benefit of the function having the same name and having the same arguments (even if carrying different arguments names) allow wallets and other smart contracts to interact with those functions using the same code. This is the main benefit of ERC20 tokens. And for this ability, to use the same coding on smart contracts and wallets this ERC20 standard was developed.

approve(address _spender, uint256 _value)

1UP code:

function approve(address _spender, uint256 _value) public returns (bool success) {

        require(balances[msg.sender] >= _value);

        allowed[msg.sender][_spender] = _value;

        emit Approval(msg.sender, _spender, _value);

        return true;


A-Token code:

function approve(address _spender, uint256 _amount) external returns(bool success) {

                                require(_spender != address(0));

                                require(_amount > 0);

                                require(_amount <= balances[msg.sender]);

        allowed[msg.sender][_spender] = _amount;

                                emit Approval(msg.sender, _spender, _amount);

                                return true;


Written the same and serve the genuine target of such ERC20 function, to allow a third party use of the account (part or all) tokens.

transferFrom(address _from, address _to, uint256 _value)

1UP code:

function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {

        uint256 allowance = allowed[_from][msg.sender];

        require(balances[_from] >= _value && allowance >= _value);

        balances[_to] = _value;

        balances[_from] -= _value;

        if (allowance < MAX_UINT256) {

            allowed[_from][msg.sender] -= _value;


        emit Transfer(_from, _to, _value);

        return true;


A-Token code:

function transferFrom(address _from, address _to, uint256 _amount) external returns(bool success) {

                                require(_from != address(0));

                                require(_to != address (0));

                                require(_amount > 0);

                                require(_amount <= balances[_from]);

                                require(_amount <= allowed[_from][msg.sender]);

                                balances[_from] = balances[_from].sub(_amount);

                                balances[_to] = balances[_to].add(_amount);

                                allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount);

                                if(tokenHoldersMap[_to] != true) {


                                                tokenHoldersMap[_to] = true;



                                emit Transfer(_from, _to, _amount);

                                return true;


Both tokens use a genuine ERC20 function that moves token from the right account to the right destination account and updates the allowance database with the proper amount (value).


1UP code:

A-Token code:

function totalSupply() external constant returns (uint) {

        return _totalSupply  - balances[address(0)];


Weird and considered as a mistake, the totalSupply function is not part of the 1UP code. While this function is just an informative one, this might hurt future communication with other smart contracts or wallets and harm the token.

As we can see this does not prevent 1UP from being an ERC20 token.

balanceOf(address _owner)

1UP code:

function balanceOf(address _owner) public view returns (uint256 balance) {

        return balances[_owner];


A-Token code:

function balanceOf(address _addr) external constant returns(uint256 balance) {

                                return balances[_addr];


Both tokens use the same code and allow users, wallets and smart contracts interact and get information about an account balance.


allowance(address _owner, address _spender)

1UP code:

  function allowance(address _owner, address _spender) public view returns (uint256 remaining) {

        return allowed[_owner][_spender];


A-Token code:

                function allowance(address _owner, address _spender) external constant returns(uint256 remaining) {

                                require(_owner != address(0));

                                require(_spender != address(0));

                                return allowed[_owner][_spender];


We have covered the six functions that are needed to define an ERC20 token.

Is our job ended?!


After we have searched those six functions we need to check the other functions that are in the smart contract. Those other functions can do certain things that we might like or dislike.

Usually we do not like that the smart contact gives unique powers to preferred accounts. For example: a major NO is the ability of a smart contract manager to print more tokens. For example: a major NO is the ability of a smart contract manager to move tokens from other people accounts. Those examples can be written into an ERC20 token.

Thus we have to know the powers given to such accounts.

In the A-Token smart contract there is no unique power or increased ability to any unique account – all accounts have the same privileges.

In the 1UP smart contract there are unique powers that were set to the owner. I trust Jeff and the Uptrennd stuff, so, I am not worried about those powers. If I were to invest in 1Ups, this is what I would do, I would ask for answers to my questions before I invest.

It is beyond our article scope to learn about the extra functions written for both ERC20 tokens that we have used for this article. And, anyway, this article becomes too long and I believe it should be ended here.


  1. ERC20 is a claim.

  2. To prove that a token meets ERC20 standards  – you have to check its' code.

  3. Never invest with a token that its' smart contract code is not an "exact match" on

  4. We only invest when we totally understand the ERC20 token smart contract.



Arik Schenkler                         

About year 2000, some 400 years ago, Arik had developed a centralized electronic money called: InternetDollar.

Arik was known in this industry and well trusted.

With the development of the A-Token, Arik wishes to return to his cryptocurrency love.

Cryptocurrency is FREEDOM!

Do Your Idea!



ATMODEPTH #Indiegamedev
31 Oct

Ok, now i know why people like this post :-)

Very nice!







Ethereum is an open-source, public, blockchain-based distributed computing platform and operating system featuring smart contract functionality.



43785 subscribers

Bitcoin Cash

28292 subscribers


27561 subscribers

Cryptocurrency Mining

26742 subscribers

Trading & TA

24144 subscribers


19247 subscribers

Uptrennd Optimization

16218 subscribers

© 2021