What, exactly, is a "Token"? - Understanding the ERC20 Standard
Tags: ethereum, smartcontracts, tokens, erc
Published: 2023-06-18 23:27:10

---
title: What, exactly, is a "Token"? - Understanding the ERC20 Standard
published: true
date: 2023-06-11 17:00:00 UTC
tags: Ethereum,SmartContracts,Tokens,ERC
canonical_url: https://byteatati.me/what-is-a-token
---

 This post was originally published **[on my blog!](https://byteatati.me/blog/what-is-a-token)**

* * *

Hello, and welcome back! Today, we’re going to dive into the intriguing world of tokens and shed light on what they how they are represented within the Ethereum ecosystem.

Tokens have become a fundamental building block in decentralized applications, enabling the creation and representation of various digital assets. In particular, we’ll focus on the ERC20 standard, which has revolutionized token development and interoperability on the Ethereum blockchain.

# The Concept of Tokens

In the realm of blockchain and cryptocurrencies, a token represents a digital asset or utility that resides on a specific blockchain. Tokens can embody various forms, such as digital currencies, digital representations of physical assets, loyalty points, and more. They are often used to facilitate transactions, govern decentralized applications, or incentivize participants within a network.

However, when Ethereum first launched, it did not natively support the creation of tokens. Instead, developers had to create their own token contracts, which were often incompatible with other applications and services. This created a lot of friction within the Ethereum ecosystem, as developers had to create custom solutions for each token.

<svg style="height:1em;font-size:3em;vertical-align:-.125em;transform-origin:center;overflow:visible" viewbox="0 0 512 512" aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg"><g transform="translate(256 256)" transform-origin="128 0"><g transform="translate(0,0) scale(1,1)"><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z" fill="currentColor" transform="translate(-256 -256)"></path></g></g></svg>

This article is about the ERC-20 standard, which covers normal fungible tokens (unlike the ERC-721 standard, which covers NFTs).

# Introducing the ERC20 Standard

The ERC20 standard, or Ethereum Request for Comment 20, is a technical specification that defines a set of rules and interfaces for creating and managing tokens on the Ethereum blockchain. It solves the need of having a standardized way for developers to create tokens, especially those that are compatible and interoperable with other Ethereum applications and services.

# How Does the ERC20 Standard Work?

To understand how the ERC20 standard works, let’s take a look at the ERC20 interface:

```solidity
interface IERC20 {
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
    
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address to, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
```

Let’s go over each of the events and functions one by one:

## Events

### `Transfer(address indexed from, address indexed to, uint256 value)`

The `Transfer` event is emitted whenever tokens are transferred from one address to another. It’s mostly self-explanatory:

- `from`: The address from which the tokens are transferred.
- `to`: The address to which the tokens are transferred.
- `value`: The amount of tokens transferred.

### `Approval(address indexed owner, address indexed spender, uint256 value)`

The `Approval` event is emitted whenever an address approves another address to spend tokens on its behalf. Again, it’s self-explanatory:

- `owner`: The address that approves `spender` to spend tokens on its behalf.
- `spender`: The address that is approved to spend tokens on behalf of the `owner`.
- `value`: The amount of tokens `spender` can spend.

## Readonly Functions

### `totalSupply()`

The `totalSupply()` function returns the total number of tokens in existence. Depending on the token, this number may be fixed or variable. For example, if the token is mintable, then the total supply may increase over time.

### `balanceOf(address account)`

The `balanceOf(address account)` function returns the number of tokens owned by a specific address. Duh.

### `allowance(address owner, address spender)`

The `allowance(address owner, address spender)` function returns the number of tokens that `spender` is allowed to spend on behalf of `owner`. This can be changed through the `approve` and `transferFrom` functions.

## State-Changing Functions

### `transfer(address to, uint256 amount)`

The `transfer(address to, uint256 amount)` function transfers `amount` tokens from the caller’s address to `to`. It returns `true` if the transfer was successful, and `false` otherwise. It’s comparable to the `send` function in Solidity.

### `approve(address spender, uint256 amount)`

The `approve(address spender, uint256 amount)` function approves `spender` to spend `amount` tokens on behalf of the caller. It returns `true` if the approval was successful, and `false` otherwise.

### `transferFrom(address from, address to, uint256 amount)`

The `transferFrom(address from, address to, uint256 amount)` function transfers `amount` tokens from `from` to `to` on behalf of the caller. It returns `true` if the transfer was successful, and `false` otherwise. It also decreases the allowance of `spender` by `amount`.

# Interoperability and Advantages of ERC20 Tokens

The ERC20 standard has revolutionized token development and interoperability within the Ethereum ecosystem. Here are some of the key advantages of ERC20 tokens:

- **Compatibility** : ERC20 tokens are compatible with a wide range of Ethereum wallets, decentralized exchanges, and other smart contracts. This compatibility enables seamless integration and broader adoption of tokens within the Ethereum ecosystem.

- **Interchangeability** : ERC20 tokens adhere to a standard interface, making them interchangeable. This means that tokens developed by different projects can be used interchangeably within the Ethereum network, fostering liquidity and usability.

- **Ecosystem Integration** : The ERC20 standard has paved the way for the development of various Ethereum-based services and decentralized applications (dApps). It has become the foundation for token crowdfunding, decentralized finance (DeFi) protocols, and other innovative use cases.

- **Token Standards** : The ERC20 standard has inspired the creation of other token standards, such as ERC721 (Non-Fungible Tokens) and ERC1155 (Multi-Token Standard). These standards cater to specific token use cases and expand the possibilities for tokenization on the Ethereum blockchain.

# Conclusion

Tokens are the digital representation of assets and utilities within the Ethereum ecosystem, enabling a wide range of applications and use cases. The ERC20 standard has played a pivotal role in token development, providing a standardized set of rules and interfaces for creating and managing tokens on the Ethereum blockchain.

With its interoperability, compatibility, and ecosystem integration, the ERC20 standard has empowered the token economy and paved the way for countless decentralized innovations. So, the next time you encounter a token on the Ethereum blockchain, remember the underlying power and significance of the ERC20 standard that makes it all possible.