BREAKING //
MemeToro Completes Stage 7 Presale • Binance Alpha Announces QAIT Airdrop • Top AI Ventures Secure $420M in Series B Deployment

What is ERC-20? The Definitive Technical & Developer Guide to Ethereum’s Fungible Token Standard

By Sandra Simon • Reviewed by Jonathan Martin & Nolan Tyler
📅 October 11, 2026 • ⏱️ 32 min read
⚡ Executive Key Takeaways
  • ERC-20 is the technical standard that defines how fungible tokens behave on Ethereum and other compatible EVM networks. It specifies a common set of smart contract functions and events that allow wallets, exchanges, and decentralized applications to interact with tokens consistently, without needing a different integration for every asset.
  • Standardized interface: Six core functions and two events define the required ERC-20 interface.
  • ETH vs. wETH: Native ETH is not an ERC-20 token; Wrapped Ether provides an ERC-20-compatible representation of ETH.
  • Approval security: Unlimited token allowances can expose your funds if an approved contract or application is compromised.
  • Modern extensions: EIP-2612 supports signature-based approvals, while ERC-4626 standardizes tokenized vaults built around ERC-20 assets.
📑 Table of Contents • Mục Lục
Xem mục lục ▼

Understanding the ERC-20 standard

ERC-20 is one of the most important technical standards in Ethereum’s application ecosystem. It gives developers a shared set of rules for creating fungible tokens, making it much easier for wallets, decentralized exchanges, lending protocols, and other applications to support assets issued by different projects.

Without a common standard, every token could implement transfers, balances, and spending permissions in a completely different way. A wallet might need custom integration logic for every asset, while a decentralized exchange would have to account for dozens of incompatible token interfaces. ERC-20 reduces that fragmentation by defining a common interface.

Origin and EIP governance

The ERC-20 proposal was introduced by Fabian Vogelsteller in November 2015, with Vitalik Buterin listed as a co-author in the proposal’s history. It became the foundation for a large share of Ethereum’s fungible-token ecosystem.

The original proposal is documented in EIP-20, the official ERC-20 specification. The document defines the functions and events that compatible token contracts must implement, along with optional metadata methods.

To understand the name, it helps to distinguish two related terms:

  • EIP: An Ethereum Improvement Proposal is a document describing a proposed standard, change, or improvement to the Ethereum ecosystem.
  • ERC: An Ethereum Request for Comments is a category of EIP used for application-level standards and conventions, including token interfaces.

ERC-20 did not create a new blockchain or introduce a separate consensus mechanism. Instead, it standardized how smart contracts on Ethereum expose token functionality.

That distinction explains why ERC-20 tokens can represent very different things despite sharing the same interface. One token might represent a governance vote, another might track a fiat currency, and another might represent a claim on assets held by a protocol. The interface can be similar even when the underlying economics and legal arrangements are completely different.

The standard also helped create a network effect. Once a wallet supports the ERC-20 interface, it can generally interact with many compliant tokens without needing a bespoke integration for each one. The same principle applies to exchanges and DeFi applications, although individual applications still need to account for unusual token behavior, network compatibility, and security risks.

For example, a token may implement the required functions but still have transfer fees, blacklisting controls, pausing mechanisms, or other restrictions. Interface compatibility does not mean every token behaves identically in every situation.

Ethereum’s official ERC-20 documentation explains how this shared interface allows fungible tokens to work across a broad range of applications.

Fungibility explained

Fungibility means that individual units of an asset are interchangeable with other units of the same asset, assuming they have the same rights and properties.

If you own 10 units of a conventional ERC-20 token, those units generally do not have separate identities that affect their value. You can transfer five units to one wallet and five to another without needing to identify each token individually.

This is similar to ordinary currency. One dollar is generally interchangeable with another dollar of the same currency, even though the physical banknotes may have different serial numbers.

ERC-20 is therefore well suited to assets such as:

  • Payment and utility tokens.
  • Governance tokens used for voting in decentralized protocols.
  • Stablecoins intended to track the value of another currency or asset.
  • Tokens representing shares or claims within financial applications.
  • Reward and loyalty tokens.

However, fungibility at the contract level does not guarantee equal market value across every trading venue. A token issued on one network may not be equivalent to a bridged representation on another network, and a stablecoin’s intended peg is not a guarantee that it will always trade at that price.

Now compare ERC-20 with ERC-721, the standard commonly associated with non-fungible tokens (NFTs).

An ERC-721 contract tracks individually identified tokens. Each token has its own token ID, allowing the contract to distinguish one asset from another. That makes the standard suitable for digital collectibles, unique game assets, and other items where individual identity matters.

The distinction is simple: ERC-20 tracks interchangeable quantities, while ERC-721 tracks individually identified assets. Other standards, including ERC-1155, support both fungible and non-fungible asset models within a shared contract architecture.

The ERC-20 smart contract interface

The ERC-20 smart contract interface

The ERC-20 standard is an interface specification, not a complete tokenomics model or a ready-made smart contract implementation.

A contract can implement the required interface while leaving important design decisions to its developer, including how tokens are created, whether they can be burned, who can mint new units, and whether transfers are restricted.

The six core functions and two events form the essential interface. Optional metadata methods provide additional information that wallets and applications commonly display.

The six mandatory interface functions

In Solidity, developers commonly interact with ERC-20 tokens through the IERC20 interface. The following functions define the basic operations of a standard token contract.

Function Purpose Typical use
totalSupply() Returns the total token supply currently recorded by the contract Displaying supply information
balanceOf(address account) Returns the token balance of an address Checking a user’s holdings
transfer(address recipient, uint256 amount) Transfers tokens from the caller to a recipient Sending tokens directly
allowance(address owner, address spender) Returns the remaining approved spending allowance Checking a contract’s permission
approve(address spender, uint256 amount) Sets an allowance for a spender Authorizing a DApp to use tokens
transferFrom(address sender, address recipient, uint256 amount) Transfers tokens from an address using an allowance or other permitted authorization mechanism Pulling tokens into a protocol

The precise requirements are described in the EIP-20 method specification. Let’s examine how each function works in practice.

totalSupply()

function totalSupply() external view returns (uint256);

This function returns the contract’s current total supply, expressed in the token’s smallest accounting units.

Suppose a token has 1 million units outstanding and uses 18 decimals. The contract will generally store a supply of:

1000000 * 10 ** 18

The value returned by totalSupply() is not necessarily the maximum supply the project will ever reach. A contract may permit additional minting, allow tokens to be burned, or impose a cap through separate logic.

It is therefore important to distinguish current supply from maximum supply. The interface tells you what the contract reports now; the contract’s implementation and administrative controls determine what may happen later.

balanceOf(address account)

function balanceOf(address account)

    external

    view

    returns (uint256);

This function returns the token balance associated with a particular address.

A wallet interface uses this information to display how many tokens you own. A lending protocol might query the same function when checking a user’s token holdings, while a decentralized exchange may use it as part of its accounting.

The function does not move tokens or create a transaction by itself. It is a read operation, so an ordinary call can usually be executed without paying an on-chain transaction fee.

One caveat: a balance tells you what the contract reports, not whether the token is liquid, valuable, transferable under every circumstance, or redeemable for another asset.

transfer(address recipient, uint256 amount)

function transfer(

    address recipient,

    uint256 amount

) external returns (bool);

The transfer() function sends tokens from the caller’s balance to the recipient’s balance.

For example, if Alice holds 100 tokens and transfers 25 to Bob, the standard accounting result is that Alice holds 75 and Bob holds 25 more than before, assuming the transfer succeeds and the token does not apply additional mechanics.

The amount is expressed in the token’s smallest units rather than the human-readable display amount. For a token with 18 decimals, sending one whole token normally requires an amount of 1018.

The function returns a Boolean value indicating success under the interface’s conventions. Developers should not assume that every real-world token follows identical failure behavior; some implementations revert on failure rather than returning false.

allowance(address owner, address spender)

function allowance(

    address owner,

    address spender

) external view returns (uint256);

This function reports how many tokens an owner has authorized a spender to use through the allowance mechanism.

Imagine that you own 500 tokens and authorize a decentralized exchange to spend up to 100. The allowance typically begins at 100 tokens. If the exchange subsequently transfers 40 tokens using transferFrom(), the remaining allowance is generally 60.

The allowance is a permission, not a token balance. You can have 500 tokens in your wallet and an allowance of zero, or a large allowance even if your wallet currently holds no tokens.

approve(address spender, uint256 amount)

function approve(

    address spender,

    uint256 amount

) external returns (bool);

This function allows the caller to set the spending allowance for another address.

The spender might be a decentralized exchange, a lending protocol, or another smart contract that needs permission to move tokens on the user’s behalf.

For example, a DApp could request approval to spend 20 tokens before depositing them into a vault. Once the allowance has been established, the protocol can call transferFrom() as part of its deposit logic.

Approval does not itself transfer tokens. It changes the permission recorded by the token contract, and the approved spender can then use that permission within its limits.

transferFrom(address sender, address recipient, uint256 amount)

function transferFrom(

    address sender,

    address recipient,

    uint256 amount

) external returns (bool);

This function allows a caller to transfer tokens from another address when the relevant authorization rules permit it.

Suppose you want to deposit 100 tokens into a lending protocol. You approve the protocol to spend 100 tokens, and the protocol then calls transferFrom() to move those tokens from your wallet into its contract.

The caller is the spender, the sender is the address whose tokens are moved, and the recipient is the address receiving them.

In conventional allowance-based ERC-20 implementations, a successful transfer generally reduces the allowance by the amount spent. The EIP-20 standard also requires implementations to handle transfers and allowances according to their specified rules, including the behavior of infinite allowances in common implementations.

There is an important security implication: an allowance gives the spender authority to move tokens without asking you to sign a new approval for every individual transfer. That is convenient for DeFi, but it means you must trust the spender’s contract and the security of the system around it.

The 2 mandatory interface events

Functions describe operations that a contract can perform. Events provide a way for external applications to observe important state changes recorded during transactions.

ERC-20 defines two core events.

The Transfer event

event Transfer(

    address indexed from,

    address indexed to,

    uint256 value

);

This event is emitted when tokens are transferred, including when tokens are minted or burned under the event conventions specified by EIP-20.

For minting, the from address is conventionally the zero address. For burning, the to address is the zero address.

Wallets, block explorers, and analytics services can read these logs to display transfers and reconstruct token activity. The event itself is not the balance change; it is a record emitted by the contract as part of the transaction.

The Approval event

event Approval(

    address indexed owner,

    address indexed spender,

    uint256 value

);

This event records an approval-related change, identifying the token owner, the spender, and the approved value.

A wallet can use this information to display token permissions, while a security dashboard can monitor changes in allowances.

One technical nuance is worth remembering: the ERC-20 specification does not require every implementation to emit an Approval event every time an allowance is reduced through transferFrom(). Some implementations do so, but applications should not assume that all token contracts produce identical event histories.

Optional metadata attributes

Many ERC-20 tokens also expose three familiar metadata functions:

function name() external view returns (string memory);

function symbol() external view returns (string memory);

function decimals() external view returns (uint8);

These functions are widely supported, but they are optional in the original ERC-20 interface.

  • name() returns the token’s human-readable name, such as Example Token.
  • symbol() returns its short ticker-like identifier, such as EXT.
  • decimals() tells applications how to format the underlying integer balances for display.

The default decimals() value in OpenZeppelin’s ERC-20 implementation is 18, although a token can override it. The OpenZeppelin ERC-20 documentation explains how this value affects display formatting without changing the contract’s underlying integer arithmetic.

Here’s the detail many new developers miss: decimals do not create fractional values inside Solidity’s integer-based token accounting. Instead, the contract stores whole-number quantities of the smallest unit, and interfaces divide those values by 10decimals for display.

For a token with 18 decimals: 1token=1018baseunits

For a token with six decimals: 1token=106baseunits

This matters when writing deployment scripts, transferring tokens programmatically, and testing balances. If you pass 100 to a function expecting base units, you are not necessarily transferring 100 whole tokens. You may be transferring only 100 of the smallest units.

Why native ETH is not an ERC-20 token

Why native ETH is not an ERC-20 token

Ethereum has a native asset called Ether (ETH), which is used to pay transaction fees and can also be transferred between accounts. Yet ETH does not implement the ERC-20 token interface.

This can seem odd at first. If ETH is the asset used throughout Ethereum, why does it need a separate wrapped version to work with many DeFi applications?

The answer lies in how Ethereum handles its native asset compared with tokens created by smart contracts.

Protocol-layer ETH vs application-layer ERC-20

ETH is part of Ethereum’s protocol-level account and transaction model. A transaction can transfer ETH by specifying a recipient and a value, while smart contracts can receive ETH through payable functions and inspect the amount using msg.value.

ERC-20 tokens work differently. Their balances and transfer rules are managed by a particular smart contract. When you transfer a token, you interact with that contract’s functions, which update the token’s internal accounting.

For example, a native ETH transfer might be initiated through a transaction that sends value to another address. An ERC-20 transfer generally calls the token contract’s transfer() method, passing the recipient and amount as arguments.

These are different execution paths, even though both can result in an asset moving from one owner to another.

Ethereum’s documentation on Wrapped Ether explains that ETH predates ERC-20 and does not conform to the token interface. This is why an application built exclusively around ERC-20 methods cannot automatically treat native ETH as if it were any other ERC-20 token.

The distinction matters to developers building decentralized exchanges, lending markets, payment applications, and token vaults. If an application expects an asset contract with methods such as balanceOf(), approve(), and transferFrom(), native ETH does not provide those methods at an ETH token contract address.

You can build separate logic for ETH, but that increases integration complexity. A common token interface makes it easier to reuse the same application logic across multiple assets.

How Wrapped Ether (wETH) solves interoperability

Wrapped Ether, commonly written as WETH or wETH, provides an ERC-20-compatible representation of ETH.

The basic model is straightforward: a user deposits native ETH into a wrapper contract and receives an equivalent amount of WETH, subject to the contract’s rules. The WETH can then be transferred, approved, or used in DeFi protocols like other ERC-20 tokens.

A simplified example:

Your wallet

Deposit 1 ETH

Deposit transaction

WETH smart contract

Receives ETH and issues WETH

ERC-20 token credited

Your wallet

Receives 1 WETH

Under a conventional fully backed wrapping model, one WETH represents one ETH held by the wrapper contract. The user can later redeem WETH for native ETH, at which point the redeemed WETH is burned or otherwise removed from circulation according to the contract’s implementation.

That does not mean every token labeled WETH on every network is automatically safe or backed in the same way. You should verify the contract address and network, particularly when interacting with wrapped assets on other chains or through bridges.

WETH is useful because it lets applications handle an ETH-denominated asset through the familiar ERC-20 interface. A decentralized exchange can use token transfer logic, a lending protocol can request allowances, and a vault can accept WETH through its standard deposit mechanism.

One practical point is easy to overlook: you still need native ETH to pay Ethereum transaction fees. Holding WETH alone does not automatically provide the native ETH required to pay for the gas used to unwrap it or perform other transactions.

The 2-step transfer mechanism: Direct transfers vs pull payments

One of the most important concepts in ERC-20 development is the difference between transferring tokens directly and authorizing a contract to pull tokens from your wallet.

The distinction explains why approving a token and depositing it into a protocol are usually separate operations.

Peer-to-peer transfers vs contract interactions

A direct token transfer calls the token contract’s transfer() function. The token contract updates its own balance accounting, but it does not automatically call arbitrary code at the recipient’s address.

Imagine sending 100 ERC-20 tokens directly to a lending protocol’s smart contract address. The token contract may successfully credit the protocol address with 100 tokens. However, the lending protocol might not execute its deposit logic, issue a receipt token, or update its internal records simply because the transfer occurred.

The tokens could end up sitting at the contract address without being credited to a user account in the way the protocol expects.

This is different from a deposit function that explicitly calls the token contract and updates the protocol’s accounting.

A conventional allowance-based flow looks like this:

Step one: Approve

You call approve(spender, amount) on the token contract, authorizing a particular spender to use up to the specified amount.

Step two: Execute the transfer

The authorized protocol calls transferFrom(sender, recipient, amount) to move the tokens within the approved allowance.

 Step three: Update protocol accounting

The protocol completes its deposit, swap, or other application-specific logic, assuming all required checks succeed.

In a typical workflow, the approval and the actual transfer are separate transactions. This can mean two gas payments, although some newer mechanisms allow the approval and subsequent operation to be bundled under suitable conditions.

Why does the standard work this way? Because ERC-20 defines how a token contract exposes balances, transfers, and allowances, but it does not define the internal business logic of every contract that receives tokens.

A lending protocol must decide how deposits affect user balances. A decentralized exchange must account for swaps and liquidity positions. A vault must track the relationship between deposited assets and issued shares. The token contract cannot safely infer all those operations from a simple transfer.

Developers should therefore avoid assuming that a successful transfer() to a contract address automatically constitutes a valid deposit. They should use the receiving protocol’s documented deposit or interaction methods.

Security and vulnerabilities

ERC-20 approvals are essential to much of DeFi, but they also create one of the most common sources of user risk.

When you approve a smart contract to spend your tokens, you give that address a level of authority over your wallet’s token balance. If the approved spender is malicious or becomes compromised, the consequences can be serious.

The infinite approval risk

Many decentralized applications request an allowance equal to the maximum possible uint256 value: 2256-1

In Solidity, this is commonly represented by type(uint256).max.

Why request such a large allowance? Convenience. With a sufficiently large allowance, the user does not have to submit a new approval transaction every time they interact with the same contract.

For a frequent DeFi user, that can reduce friction and avoid repeated gas costs. But it also increases the amount of authority granted to the spender.

Suppose you hold 5,000 tokens and approve a protocol to spend an effectively unlimited amount. You may initially deposit only 100 tokens, but the remaining allowance could still permit the approved spender to transfer other tokens of the same contract that you hold in your wallet.

The exact risk depends on the spender’s implementation, permissions, and security. If the approved contract is exploited in a way that lets an attacker use its token-spending authority, the attacker may be able to drain funds from users who granted allowances.

An unlimited approval does not itself transfer your tokens or guarantee that the spender is malicious. It does, however, leave a broad permission in place until it is consumed, changed, or revoked.

The Revoke.cash guide to token approvals explains how token allowances work and why users should regularly review the permissions attached to their wallets.

Mitigating allowance risks

You do not need to avoid every approval to use DeFi, but you should understand what you are authorizing.

Here are several practical habits that reduce unnecessary exposure:

  • Approve only what you need. If you plan to deposit 100 tokens, consider approving 100 rather than granting an unlimited allowance, provided the application supports this workflow.
  • Check the spender address. Confirm that the contract receiving permission matches the official application and network you intended to use.
  • Review old permissions. Allowances granted months ago may remain active even if you no longer use the application.
  • Use reputable tools and interfaces. An established project is not risk-free, but checking contract documentation, audits, and security disclosures is better than approving an unknown address.
  • Revoke permissions you no longer need. Tools such as Revoke.cash let users inspect and revoke supported token approvals. Revocation typically requires an on-chain transaction and may incur a gas fee.
  • Keep your wallet environment secure. A malicious website can trick you into signing an approval transaction even when the wallet itself is functioning correctly.

There is one subtle issue with changing an existing allowance. Some ERC-20 implementations and application interfaces warn about the risk of changing an allowance directly from one nonzero value to another. Under certain transaction-ordering conditions, a spender may use the old allowance before the new approval takes effect, then use the new allowance as well.

One common mitigation is to set the allowance to zero before establishing a different nonzero value, when supported by the token and the application. This is not a substitute for understanding the contract, but it can reduce the risk associated with changing allowances.

For developers, the safest approach is to use well-tested token-handling libraries, understand the behavior of the assets being integrated, and avoid granting permissions broader than the application needs.

Re-entrancy vectors in advanced variants

ERC-20’s basic transfer model is relatively simple, but token contracts and token-integrating applications can introduce more complicated execution paths.

Re-entrancy occurs when an external call allows control to return to a contract before the original operation has completed, potentially letting an attacker invoke sensitive logic again while the contract is in an inconsistent state.

The risk is especially relevant to token standards that include hooks or callback behavior. ERC-777, for example, defines sender and recipient hooks that can execute additional code during token operations. These hooks can create re-entrancy concerns if the receiving application does not account for them correctly.

A conventional ERC-20 transfer() call does not automatically invoke arbitrary recipient code simply because the recipient is a smart contract. But that does not make every ERC-20 integration safe. An application may call an untrusted contract during its own deposit, withdrawal, or accounting logic, or may interact with unusual tokens that behave differently from expected.

Developers should follow established security patterns:

  • Update or validate critical accounting state before making potentially dangerous external calls, where appropriate.
  • Apply checks-effects-interactions and use re-entrancy guards when the design calls for them.
  • Use secure token-handling utilities, such as OpenZeppelin’s SafeERC20, to handle common differences in token return behavior.
  • Test interactions with malicious or nonstandard token contracts instead of assuming every asset behaves exactly like a simple implementation.

Security depends on the complete execution path, not merely on whether a contract claims to implement ERC-20.

Modern extensions to ERC-20

Modern extensions to ERC-20: EIP-2612 Permit and ERC-4626 vaults

ERC-20 provides a useful baseline, but modern DeFi applications need more than basic transfers and allowances. Two important extensions address different problems: EIP-2612 introduces signature-based approvals, while ERC-4626 standardizes how tokenized vaults expose deposits, withdrawals, and share accounting.

Neither replaces the underlying ERC-20 interface entirely. Instead, each builds on it to make specific application patterns easier to integrate.

EIP-2612: Permit signatures and gasless approvals

With conventional ERC-20 approvals, a user usually submits an on-chain transaction to call approve(). That transaction requires gas paid in the network’s native asset.

EIP-2612 introduces a permit() function that allows a token holder to authorize an allowance through a cryptographic signature. A relayer or another party can submit that signature to the token contract, which verifies it and updates the allowance if the conditions are valid.

The official EIP-2612 specification defines the required signature fields, including the owner, spender, allowance value, nonce, and deadline.

The mechanism generally works like this:

  • You sign structured data authorizing a particular spender and allowance.
  • The signature is provided to a transaction sender or relayer.
  • The relayer calls permit() on the token contract.
  • The contract verifies the signature, checks the nonce and deadline, and updates the allowance if validation succeeds.

The signature follows the typed-data approach defined by EIP-712, which helps bind the signed message to structured fields and a domain such as the relevant contract and chain.

A key benefit is that the user does not necessarily need to pay for a separate approval transaction. Another party can submit the permit transaction and pay its gas, although that party may have its own economic incentives or requirements.

Permit signatures can also improve the user experience when a DApp combines approval and an application operation into a single transaction. For example, a protocol may accept a permit signature and then perform a deposit, provided its implementation supports that flow.

However, EIP-2612 does not make every token support permit automatically, and it does not make transactions free for the entire system. The transaction still consumes gas; someone must pay for it. The standard simply changes how the allowance authorization is delivered.

There are security considerations, too. A signature is a permission, and users should verify the spender, amount, chain, and deadline before signing. Applications must also handle expired signatures, reused nonces, and failed permit calls correctly.

ERC-4626: Tokenized yield-bearing vaults

ERC-4626 addresses a different problem: how applications should interact with vaults that accept an underlying ERC-20 asset and issue shares representing a claim on the vault.

Imagine depositing USDC into a yield-bearing vault. The vault holds or deploys the underlying assets according to its strategy and issues vault shares to represent your ownership interest. Those shares may be transferable and can themselves be used by other DeFi applications, subject to the vault’s design.

Before ERC-4626, different vaults could expose different deposit, withdrawal, and accounting interfaces. Integrators often needed custom logic to support each implementation.

The official ERC-4626 specification establishes a standard interface for tokenized vaults built around a single underlying ERC-20 asset.

Important functions include:

Function Purpose
asset() Identifies the underlying ERC-20 asset
totalAssets() Reports the underlying assets managed by the vault
convertToShares() Estimates the shares corresponding to a quantity of assets
convertToAssets() Estimates the assets corresponding to a quantity of shares
deposit() Deposits assets and issues shares
withdraw() Withdraws a specified quantity of assets
redeem() Redeems a specified quantity of shares for assets

The core idea is standardization. A lending aggregator or portfolio application can integrate with a vault through a common interface rather than learning an entirely different API for each vault.

But standardized interfaces do not guarantee investment performance. A vault may lose money through strategy losses, smart contract exploits, liquidity constraints, or other risks. Fees and share-conversion mechanics also affect the amount users receive.

For developers, ERC-4626 is particularly useful when building yield products, lending integrations, and composable financial applications. For users, it makes the basic mechanics more consistent without removing the need to understand the vault’s strategy and risk profile.

ERC-20 vs other token standards

Ethereum supports multiple token standards because different assets require different behaviors. ERC-20 focuses on interchangeable balances, while other standards support individually identified assets, mixed asset types, or additional transfer interactions.

The best choice depends on what the application needs to represent and how other contracts must interact with it.

Standard Primary use case Fungibility Main advantage Notable feature
ERC-20 Currency, governance, and financial tokens Fungible Broad wallet and DeFi compatibility Standard balances and allowances
ERC-721 NFTs, collectibles, and unique assets Non-fungible Distinct token IDs and ownership Individual asset identity
ERC-1155 Gaming items and mixed asset collections Fungible and non-fungible patterns Multiple token types in one contract Batch operations
ERC-1363 Tokens requiring transfer or approval callbacks Fungible Enables defined interactions after transfers or approvals transferAndCall() and related methods
ERC-4626 Tokenized yield-bearing vaults Fungible shares Standardized vault accounting Asset deposits and share redemption

When should you use each standard?

ERC-20 is the natural starting point for fungible assets. If your project needs a transferable token with balances, allowances, and compatibility with established DeFi interfaces, this is generally the standard to evaluate first.

ERC-721 is appropriate when individual identity matters. A digital artwork or collectible may have a distinct token ID and metadata that separate it from every other item in the collection.

ERC-1155 is useful when one contract needs to manage multiple asset types. A blockchain game might use it to represent both interchangeable consumables and individually tracked equipment. Its batch-transfer functionality can also reduce overhead in suitable operations.

ERC-1363 adds explicit callback functionality. It defines methods that allow a token transfer or approval operation to trigger a receiver or spender’s specified callback. This can be useful for applications that need the token movement and the follow-up interaction to happen together. The callback behavior also means developers must consider re-entrancy and receiver validation.

ERC-4626 is designed for vault shares rather than generic token issuance. It standardizes the relationship between underlying assets and the shares representing a claim on those assets.

These standards are not all direct competitors. ERC-4626 builds on ERC-20, while ERC-1363 extends the transfer-and-approval interaction model. ERC-721 and ERC-1155 address different asset representation requirements.

If you’re building a new project, avoid choosing a standard simply because it is popular. Start by defining the asset model, ownership rules, transfer behavior, and application integrations. Then choose the interface that best fits those requirements.

How to deploy an ERC-20 token using Solidity and OpenZeppelin

If you want to create an ERC-20 token, you do not need to implement every balance update, allowance check, and transfer event from scratch. A widely used approach is to build on a reviewed library such as OpenZeppelin Contracts, then add only the tokenomics and access-control logic your project actually requires.

The example below creates a token named MyToken, with the ticker MTK, and mints an initial supply to the deployer’s address.

Create the token contract

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import “@openzeppelin/contracts/token/ERC20/ERC20.sol”;

contract MyToken is ERC20 {

    constructor(uint256 initialSupply)

        ERC20(“MyToken”, “MTK”)

    {

        _mint(

            msg.sender,

            initialSupply * 10 ** decimals()

        );

    }

}

This example uses OpenZeppelin’s ERC-20 implementation rather than manually implementing the standard’s required functions.

Let’s break down the important parts.

  • SPDX license identifier: MIT declares the license associated with the source code. You should use a license that accurately reflects the rights you intend to grant.
  • Solidity version: pragma solidity ^0.8.20; specifies the compatible compiler range. Your development environment must use a compiler version that satisfies this requirement.
  • OpenZeppelin import: The contract inherits standard ERC-20 functionality from the library.
  • Constructor: The token is initialized with the name MyToken and symbol MTK.
  • Initial mint: _mint() creates the initial supply and credits it to msg.sender, which is the address deploying the contract.

There is an important detail in the constructor. The initialSupply parameter represents a human-readable number of whole tokens, not the raw integer quantity used internally. Multiplying it by 10 ** decimals() converts it into the contract’s base units.

For example, passing 1_000_000 creates an initial supply of one million tokens when the contract uses 18 decimals.

The example does not impose a maximum supply or give anyone a function to mint additional tokens after deployment. As written, it creates the initial supply in the constructor and provides no additional minting function. If you want ongoing issuance, burning, pausing, or administrative controls, you must implement those requirements explicitly and consider their security implications.

OpenZeppelin’s ERC-20 documentation provides further details about inheritance, token extensions, and implementation behavior.

Set up your development environment

You can use either Foundry or Hardhat to compile, test, and deploy the contract. Both are established Ethereum development toolchains, but they differ in their workflows and preferred testing languages.

For a beginner, I recommend starting with one environment rather than switching between them while learning Solidity.

Foundry

Foundry provides tools for compiling, testing, deploying, and interacting with smart contracts. Its core workflow uses Solidity for tests and command-line tools for development.

Documentation: getfoundry.sh

Hardhat

Hardhat provides a development environment for compiling, testing, debugging, and deploying smart contracts, commonly using JavaScript or TypeScript alongside Solidity.

Documentation: hardhat.org

Whichever framework you choose, your basic workflow is similar.

Install dependencies and compile

First, create a project and install the relevant development tools. Add the OpenZeppelin Contracts dependency to your project, then save the Solidity contract in the appropriate source directory.

Compile it and resolve any compiler errors before moving forward. Compiler success confirms that the source code is valid for the selected compiler configuration; it does not prove that the contract is secure or economically sound.

Write tests before deployment

At a minimum, test the following behavior:

  • The constructor assigns the expected initial supply to the deployer.
  • totalSupply() returns the expected amount in base units.
  • balanceOf() reports the correct balances.
  • Transfers update sender and recipient balances correctly.
  • An account cannot transfer more tokens than it owns.
  • Allowances behave correctly after approval and transferFrom().
  • Unauthorized accounts cannot access any privileged functionality you add.

You should also test boundary conditions, including zero-value transfers where relevant, invalid recipients, and allowance changes.

If you extend the contract with minting, pausing, burning, or administrative permissions, add tests for both authorized and unauthorized calls. A contract that behaves correctly under normal conditions may still have serious access-control weaknesses.

Deploy to a test network

Before spending real funds on deployment, test the contract on an appropriate Ethereum test network. Configure the RPC endpoint, deployment account, and network settings in your chosen toolchain.

Never place a wallet’s private key directly into source code or commit it to a public repository. Use a secure secret-management approach and a dedicated deployment account with appropriate funding.

Once deployed, record the contract address and verify that the deployment matches the expected bytecode and constructor parameters.

Verify the contract on Etherscan

Contract verification publishes the source code and compiler configuration associated with a deployed contract so users can compare the source against the deployed bytecode.

Etherscan’s contract verification documentation explains the verification process and its requirements.

Verification is useful for transparency, debugging, and integration, but it is not a security audit. It shows how the deployed contract corresponds to the submitted source under the relevant verification process; it does not establish that the contract is free from vulnerabilities.

Before a production launch, review the full token design, access controls, deployment configuration, and upgradeability assumptions. If the token will handle significant value, an independent security review is a sensible part of the process.

Decide on tokenomics before launching

The code above is intentionally minimal. A production token needs a clear policy for how supply will work.

Ask yourself:

  • Is the supply fixed, or can additional tokens be minted?
  • Who, if anyone, can mint or burn tokens?
  • Will the contract include a cap, a pause mechanism, or other restrictions?
  • Are the token’s administrative permissions controlled by one wallet, a multisignature wallet, or a governance system?
  • What happens if an administrative key is compromised?
  • How will users and exchanges verify that they are interacting with the correct contract?

The answers should be documented before deployment. A token can follow the ERC-20 interface perfectly and still have poor tokenomics, unsafe permissions, or misleading claims about its utility.

Frequently asked questions about ERC-20

What is ERC-20, and why is it important for Ethereum?

ERC-20 is a technical standard for fungible tokens implemented through smart contracts on Ethereum and compatible EVM networks. It defines a common interface that helps wallets, exchanges, and decentralized applications interact with different tokens consistently.

What are the six mandatory functions of an ERC-20 smart contract?

The six core functions are totalSupply(), balanceOf(), transfer(), allowance(), approve(), and transferFrom(). Together, they provide the basic interface for querying supply and balances, transferring tokens, and managing spending permissions.

What is the difference between native ETH and an ERC-20 token?

ETH is Ethereum’s native asset, handled by the protocol’s account and transaction mechanisms. ERC-20 tokens are managed by smart contracts that expose standardized methods for balances, transfers, and allowances.

Why do we need Wrapped Ether (WETH)?

WETH represents ETH through an ERC-20-compatible smart contract, allowing applications built around ERC-20 interfaces to interact with an ETH-denominated asset. Users can generally deposit ETH to receive WETH and redeem WETH for ETH through the relevant wrapper contract.

How does the approve and transferFrom mechanism work?

The token owner calls approve() to authorize a spender to use a specified amount of tokens. The spender can then call transferFrom() to move tokens from the owner’s balance within the applicable authorization limits.

What is EIP-2612 Permit, and how does it save gas?

EIP-2612 allows a token holder to authorize an allowance using a cryptographic signature rather than submitting a separate on-chain approve() transaction. A relayer or another transaction sender can submit the signature, potentially allowing approval and a subsequent DeFi operation to be bundled together.

What are the security risks of granting infinite token approvals?

An unlimited approval may allow a spender to transfer tokens from your wallet up to the approved limit, even if you initially use the application for a much smaller transaction. If the spender is compromised or malicious, that permission can expose your holdings, so review allowances and revoke unnecessary approvals.

Final thoughts: ERC-20 is a foundation, not a security guarantee

ERC-20 made Ethereum’s token ecosystem easier to build because it gave developers a common language for balances, transfers, and spending permissions. That standardization is a major reason fungible tokens can integrate with so many wallets, exchanges, and DeFi applications without requiring an entirely new interface for every asset.

But there is a distinction I would keep in mind whether you’re writing Solidity or simply using crypto: standardized behavior does not automatically mean safe behavior.

For developers, understanding the six core functions is only the starting point. You also need to think about token issuance, access control, allowance handling, unusual token implementations, and how your contract interacts with external applications. Libraries such as OpenZeppelin reduce the need to reinvent established functionality, but they cannot make poor design decisions harmless.

For investors and DeFi users, the same principle applies from a different angle. A token’s ERC-20 compatibility tells you how it is expected to interact with applications; it does not prove that the project is legitimate, the token has value, or the contract can redeem the asset for anything else.

If you understand the interface, know what permissions you are granting, and verify the contracts you interact with, ERC-20 becomes much easier to work with-and much easier to evaluate critically.

TAGS:
Jonathan Martin
Senior Tech & Financial Analyst

Jonathan Martin is the Founder & CEO of Mr. Hunter 1988, where he leads the company's mission to deliver trustworthy financial education, independent market analysis, and practical trading resources for investors around the world.

🛡️ Editorial & Financial Disclaimer

Disclaimer: Mr. Hunter 1988 is an independent financial and technology intelligence publication. The content provided on this website does not constitute financial, investment, legal, or trading advice. Cryptocurrencies, digital assets, and startup equity investments involve substantial risk of volatility and capital loss. Readers must conduct their own independent due diligence (DYOR) and consult certified financial advisors before executing any financial commitments.

Share with