Member-only story
Dissection of an ERC-20 StableCoin: Understanding the stablecoin smart contract (Part Two)

This is the continuation of my study of stablecoin smart contract. In the previous part, we introduced the smart contract code, illustrated a dependency mapping among the contracts and interfaces, started describing the abstract contracts, and we could cover up to PausableUpgradeable
. You can find all the parts of the article in the following links:
Let’s jump right into the smart contract!!!
Interface IERC20Upgradeable {}
The provided IERC20Upgradeable
interface defines the standard functions and events for ERC20 tokens, as described in the Ethereum Improvement Proposal (EIP) 20. ERC20 is one of the most widely adopted standards for fungible tokens on Ethereum and other blockchain networks.
Key Functions and Events in IERC20Upgradeable
Events
- Transfer:
- Emitted when tokens are moved from one account to another.
- Includes the sender’s address (
from
), the receiver's address (to
), and the number of tokens moved (value
). - This event also fires when
value
is zero, to reflect zero-value transfers.
2. Approval:
- Emitted when a spender’s allowance for an owner’s tokens is set or updated.
- Includes the owner (
owner
), the spender (spender
), and the updated allowance (value
).
Functions
1. totalSupply()
:
- Returns the total amount of tokens in existence.
- This function allows for querying the overall supply of the ERC20 token.
2. balanceOf(address account)
:
- Returns the token balance of the specified account (
account
). - The balance represents how many…