0Pricing
Web3 & DApp Development Fundamentals · Lektion

Der ERC-20-Standard

Token-Schnittstelle

Der ERC-20-Standard ist eine kostenlose Web3 & DApp Development Fundamentals-Lektion auf CoddyKit. Dies ist Lektion 1 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Web3 & DApp Development Fundamentals-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Web3 & DApp Development Fundamentals-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

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 movement
  • Approval - 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

Häufig gestellte Fragen

Ist die Lektion „Der ERC-20-Standard“ kostenlos?

Ja — der vollständige Text von „Der ERC-20-Standard“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Web3 & DApp Development Fundamentals-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Web3 & DApp Development Fundamentals-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Der ERC-20-Standard“?

Token-Schnittstelle Du übst Web3 & DApp Development Fundamentals mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Web3 & DApp Development Fundamentals zu starten?

Keine Vorkenntnisse erforderlich. Web3 & DApp Development Fundamentals auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 1 von 4.

Wie lange dauert die Lektion „Der ERC-20-Standard“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Web3 & DApp Development Fundamentals-Lektion Code schreiben und ausführen?

Ja. Jede Web3 & DApp Development Fundamentals-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Der ERC-20-Standard
  2. Einen Token implementieren
  3. Allowances
  4. Minting und Burning
← Zurück zu Web3 & DApp Development Fundamentals