Why we love ERC20

Cryptopusco
2 min readFeb 17, 2018

--

What is interesting about ERC20 standard? It lets people interact with tokens over contracts. It lets third party applications use the contract. For example, imagine you have a token, which lets you upload data to the server. This process involves Terminal commands and it’s not that easy for clients. Due to some reasons authors of the project don’t want to develop any kind of UX/UI, but let others do it with ease, because the token is built on top of ERC20.

What kind of magic happens here? ERC20 standard contains 6 essential functions, that let anyone get total supply, balances of users, transfer tokens and allow others to transfer tokens.

Talking about cryptopus we had developed a great pre-ICO contract, which is also built using ERC20. We have sold a lot of tokens using it and now it’s time to exchange those tokens to the ICO tokens, because we aren’t going to accept pre-ICO tokens inside of our eco-system. How could someone do this? Really fast and easy:

First of all make sure you have your ERC20 interface included. After that, just create a functions, like exchangeTokens(uint tokens):

Let us explain what this function does:

  1. It checks that the right amount of tokens is allowed by the user to be transferred by the contract.
  2. In case it returns true, it transfers tokens using transferFrom() (ERC20 standard function). It transfers tokens to 0x0 address, which also means, that tokens are going to be “burned”. Actually, tokens will stay at this address forever.
  3. It updates balances of users in current contract, so they will receive the right amount of tokens back.
  4. It fiers up event called Transfer and returns true as a result of the function call.

Really elegant and easy-to-understand mechanism, which lets anyone exchange tokens to tokens. It also could be used for many other reasons, but we let you guys find out them on yourselves! Thank you for reading this post and please, subscribe to out account.

P.S. here is the link to our new contract published on github: https://github.com/cryptopus/cryptopus_ITO_contract

--

--

Cryptopusco

IPFS-based, open-source blockchain tech brokerage marketplace where cryptocurrency investors choose inkognito traders based on their result of the job.