A Brief Introduction to Blockchain Tokens
By Juan Tavira, Senior Blockchain Architect & Identity Expert at Banco Santander.
The basics of blockchain must include some knowledge about tokens. Talking of Ethereum (and EVM compatible networks) there’s a native token to the network, the one that is built-in the core functionality, that is ETH (in Ethereum).
ETH is a native token because there is not deployed SmartContract that handles it. You can transfer ETH by simply executing a “sendTransaction” from your address to the designatory address and adding the value to be transferred. The ETH balance is automatically managed and updated in your address 📬.
Other tokens rely on an SmartContracts.
An SmartContract is some code deployed and executed in a blockchain network. Tokens’ SmartContracts handle the balance of the tokens and the rules to manage it.
What kind of tokens are out there? Lots of them. A this is an introduction we will explain just two ✌️ of them, the most used and well-known: ERC20 and ERC721.
ERC20
ERC20 is the standard for fungible tokens, and it has many uses. You can read 🧐 more about it here: https://ethereum.org/en/developers/docs/standards/tokens/erc-20/ (introduction) and here https://eips.ethereum.org/EIPS/eip-20 (the standard explained) but the basics are here 👇:
Each address has a balance of the tokens it owns, and all the tokens are exactly the same, that’s why there is no need to individually name each token, like money in the bank: you have a balance and you do not name individually each single penny in your account.
In opposition to ETH that has the transfer capability built-in the ERC20 tokens need each one of their capabilities to be defined and implemented in its SmartContract. One widely used SmartContract for ERC-20 can be found here: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol and the functions (capabilities) implemented cover:
✔️ name() and symbol() to get the token name and its symbol and decimals() to know the units handled by the token.
✔️ totalSupply() and balance() give us information on the total number of tokens minted and the balance of a given address.
✔️ Finally, the transfer options: transfer() to move tokens to other addresses and approve() so a third party can transfer some of your tokens. There are also a few other accessory functions.
At the end what we have is a program and its data (the SmartContract) that rule the token. If there’s a bug, a flaw or a malicious design the tokens could be gone easily, that’s why successful tokens rely on public and tested SmartContracts that you deploy for your own token.
What about ERC721, the NFTs?
Another standard, different SmartContract code, meaning different capabilities.
The obvious difference between ERC721 and ERC20 is that each ERC721 are non-fungible, meaning that each token is different from another, it has its own unique characteristics. Starting for an identifier for each token but not limited to that, as NFTs usually have externally linked resources (like an image or video), name, rarity and whatever characteristics the designer 🧑💻 wants to add to them.
But regarding the functions of the ERC721 SmartContract they are pretty the same as ERC20 bearing in mind that each token is managed individually and not in bulk in a balance. The source code for ERC721 by OpenZeppelin can be found here: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol and there is some technical explanation here: https://docs.openzeppelin.com/contracts/3.x/erc721
ETH exists since Ethereum was created and ERC20/ERC721 have been around for some time, ERC20 since 2015 and ERC721 since 2018.
Now, two more questions for our next article:
1️⃣ Which other token standards exist?
2️⃣ Are there any token standards that implement business/regulation capabilities?
Before you go:
Clap if you liked it 👏, comment and share this article to reach more community 🧞.
Would you like to be part of our technology project? Find our open vacancies worldwide here 👉 https://www.betechwithsantander.com/en/home