Member-only story

Exploring ERC20 Fungible Token Standard in Solidity

Meet the gold standard for tokens on EVM chains

Kristaps Grinbergs
Better Programming
5 min readSep 12, 2022

--

Photo by regularguy.eth on Unsplash.

This time let’s talk about fungible tokens, one of the main building blocks in DeFi. These tokens can represent coins, gold, grain, and other assets that can be exchanged for them. We will look into one of the first Ethereum Improvement Proposal with number 20. This token standard is widely known as ERC20 and describes an interface for tokens within smart contracts. Functions like token transferring, approving spending, creating, and others are defined by this ERC20 standard.

To illustrate the ERC20 standard in code, we will use OpenZepplin ERC20 implementation.

Minting and burning

There are two main actions with total token supply. We can use either mint or burn them. Minting means creating more supply, and burning means decreasing supply once we need to do so.

Minting

To create a token supply, we need to mint this amount. When we are minting behind, the scenes caller that calls this function receives provided amount of tokens.

Let’s create a smart contract that would act as an ERC20 token. In the constructor, we need to provide the total token supply and call OpenZepplin’s ERC20 implementation constructor…

--

--

Kristaps Grinbergs
Kristaps Grinbergs

Written by Kristaps Grinbergs

Blockchain, mobile and fullstack developer. Startup founder. Conference speaker. Mentor. Passionate about building products, sustainability and Web 3.0.

No responses yet

What are your thoughts?