ERC-20 표준
토큰 인터페이스
ERC-20 표준은(는) CoddyKit의 무료 Web3 & DApp Development Fundamentals 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Web3 & DApp Development Fundamentals 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Web3 & DApp Development Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
What Is ERC-20?
ERC-20 is the standard interface for fungible tokens on Ethereum. Fungible means every unit is identical and interchangeable, like currency.
Because all ERC-20 tokens share the same interface, wallets and exchanges can support any of them automatically.
The Required Functions
An ERC-20 token must implement six functions:
totalSupply()balanceOf(account)transfer(to, amount)approve(spender, amount)allowance(owner, spender)transferFrom(from, to, amount)
The Two Events
ERC-20 also requires two events so wallets can track activity:
Transfer- fired on any token movementApproval- fired when an allowance is set
<code>event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);</code>totalSupply and balanceOf
totalSupply() returns the total number of tokens in existence. balanceOf(account) returns how many tokens a given address holds.
<code>function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);</code>The Interface in Code
Solidity lets you declare the standard as an interface. Implementations inherit from it to guarantee compliance.
<code>interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}</code>Optional Metadata
Three optional functions improve display: name(), symbol(), and decimals(). They are not required by the core standard but are expected by wallets.
<code>function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);</code>Understanding Decimals
The EVM has no fractions, so tokens use decimals to represent fractional amounts. Most tokens use 18 decimals, matching Ether.
So 1 token displayed equals 1 * 10**18 in raw units.
<code>uint8 public constant decimals = 18;
// 1 token = 1_000_000_000_000_000_000 base units</code>Why a Standard Matters
Because ERC-20 defines a common shape, a wallet can display any token, a DEX can trade it, and a contract can integrate it without custom code. Interoperability is the whole point.
Return Values
The mutating functions transfer, approve, and transferFrom return a bool indicating success. Most modern implementations revert on failure rather than returning false.
<code>function transfer(address to, uint256 amount) external returns (bool);
// returns true on success; reverts on insufficient balance</code>Using OpenZeppelin
In practice most developers do not write ERC-20 from scratch. They inherit the battle-tested OpenZeppelin implementation and just set the name, symbol, and initial supply.
<code>// import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
// contract MyToken is ERC20 {
// constructor() ERC20('MyToken', 'MTK') {
// _mint(msg.sender, 1000 * 10 ** decimals());
// }
// }</code>The Allowance Mechanism
A defining ERC-20 feature is allowances: an owner can authorize a spender to move tokens on their behalf via approve and transferFrom. This powers DEXs and DeFi protocols.
You will explore this in detail later in the course.
Quick Check
Test your understanding of the ERC-20 standard.
Recap
You learned the ERC-20 standard:
- It defines fungible tokens with a common interface
- Six required functions plus Transfer and Approval events
- Optional name, symbol, and decimals for display (usually 18 decimals)
- Allowances enable delegated transfers
- OpenZeppelin provides a safe ready-made implementation
자주 묻는 질문
“ERC-20 표준” 강의는 무료인가요?
네 — “ERC-20 표준” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Web3 & DApp Development Fundamentals 강의 전체를 잠금 해제할 수 있습니다. Web3 & DApp Development Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.
“ERC-20 표준”에서 뭘 배우나요?
토큰 인터페이스 브라우저에서 직접 실행하는 실습 코드로 Web3 & DApp Development Fundamentals을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Web3 & DApp Development Fundamentals을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Web3 & DApp Development Fundamentals은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.
“ERC-20 표준” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Web3 & DApp Development Fundamentals 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Web3 & DApp Development Fundamentals 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.