Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
ERC-6093 proposes standardized custom errors for tokens implementing ERC-20, ERC-721, and ERC-1155.
This article translates, summarizes, and expands on the following proposal.
As of September 17, 2023, ERC-6093 was in the Last Call stage.
Overview
This Ethereum Improvement Proposal (EIP) is a standard for token smart contracts on Ethereum. It specifically concerns ERC-20, ERC-721, and ERC-1155 tokens.
Ethereum applications and wallets display error messages when transactions fail so that users can understand what went wrong. Historically, these messages were provided as simple text strings. More recent versions of Solidity introduced custom errors, which can carry detailed information associated with a particular error.
The goal of this EIP is to standardize information about the causes and details of transaction failures. Structured errors are easier for client applications to decode. Users receive more understandable information about transaction failures, and developers can handle errors more effectively.
For more on ERC-20, see the following article.
For more on ERC-721, see the following article.
For more on ERC-1155, see the following article.
Motivation
Solidity 0.8.4 introduced custom errors. They make it possible to present more detailed and understandable information when transactions fail. Custom errors can carry dynamic information, such as arguments, while improving gas efficiency and reducing deployment costs.
Errors become more informative, transaction processing becomes more efficient, and the costs associated with contract deployment and execution can be reduced.
However, custom errors were introduced after token standards such as ERC-20, ERC-721, and ERC-1155 had already been finalized. These standards therefore did not specify custom errors.
Applications and contracts using these tokens lacked a common set of custom errors for reporting failures.
This EIP introduces standardized errors. Users can expect consistent error information across applications and test environments. Relevant information and arguments can also be included in each error. Reducing the need to embed revert strings in deployment bytecode lowers costs and improves the user experience.
Specification
The EIP defines a list of errors that implementations can use in specific situations. These errors follow the rationale described in the proposal.
There is an important qualification. The EIP does not prescribe whether an implementation must revert in every situation covered by these errors. In other words, it does not independently require an implementation to report each of these errors. Error handling remains the responsibility of the implementer, such as the smart contract developer. The exception is when the corresponding token standard explicitly requires a revert.
Error argument names are defined in the Parameter Glossary and must be used exactly as specified. This maintains consistency and makes errors easier to understand.
ERC20
ERC20InsufficientBalance
event ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);Overview
A custom error concerning the token sender's balance.
Details
Used when the sender does not hold enough tokens.
It applies when the sender's balance is below the needed amount.
Parameters
sender- Address of the sender.
balance- Current balance of the sender.
needed- Required balance.
ERC20InvalidSender
event ERC20InvalidSender(address sender);Overview
A custom error concerning the token sender. Typically used during token transfers.
Details
Used when the token sender is invalid. For example, when sending tokens from the zero address is not permitted. It should not be used for approval operations or balance and approval requirements.
Parameters
sender- Address of the invalid sender.
ERC20InvalidReceiver
event ERC20InvalidReceiver(address receiver);Overview
A custom error concerning the token recipient. Typically used during token transfers.
Details
Used when the token recipient is invalid. For example, when transfers to the zero address or an incompatible address, such as a contract address, are not permitted. It should not be used for approval operations.
Parameters
receiver- Address of the invalid recipient.
ERC20InsufficientAllowance
event ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);Overview
A custom error concerning a token allowance. Typically used during token transfers.
Details
Used during a token transfer when the approved allowance is less than the needed amount.
Parameters
spender- Address of the spender authorized to use the tokens.
allowance- Approved token amount.
needed- Required allowance.
ERC20InvalidApprover
event ERC20InvalidApprover(address approver);Overview
A custom error concerning the token approver. Typically used during token approval operations.
Details
Used when the token approver is invalid. For example, when approvals from the zero address are not permitted. It should not be used for token transfers.
Parameters
approver- Address of the invalid approver.
ERC20InvalidSpender
event ERC20InvalidSpender(address spender);Overview
A custom error concerning the recipient of a token approval. Typically used during token approval operations.
Details
Used when the recipient of a token approval is invalid. For example, when approvals to the zero address or to the token owner are not permitted. It should not be used for token transfers.
Parameters
spender- Address of the invalid spender.
ERC721
ERC721InvalidOwner
event ERC721InvalidOwner(address owner);Overview
A custom error indicating that a particular address cannot be a token owner. Typically used when querying token ownership.
Details
Used when an address is not recognized as a valid token owner. For example, ERC-721 may reject the zero address as an owner.
Parameters
owner- Address not recognized as a valid owner.
ERC721NonexistentToken
event ERC721NonexistentToken(uint256 tokenId);Overview
A custom error identifying the tokenId of a token that has no owner.
Details
Used when the specified tokenId does not exist, for example because the token has not been minted or has been burned.
Parameters
tokenIdtokenIdof the nonexistent token.
ERC721IncorrectOwner
event ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);Overview
A custom error concerning ownership of a particular token. Typically used during token transfers.
Details
Used when the specified token sender is not its actual owner.
It should not be used for approval operations.
Parameters
sender- Token sender.
tokenId- Token
tokenId.
- Token
owner- Actual owner.
ERC721InvalidSender
event ERC721InvalidSender(address sender);Overview
A custom error concerning the token sender. Typically used during token transfers.
Details
Used when the token sender is invalid. For example, when sending tokens from the zero address is not permitted. It should not be used for approval operations or ownership and approval requirements.
Parameters
sender- Address of the invalid sender.
ERC721InvalidReceiver
event ERC721InvalidReceiver(address receiver);Overview
A custom error concerning the token recipient. Typically used during token transfers.
Details
Used when the token recipient is invalid.
For example, when transfers to the zero address or contracts that do not support ERC-721 token reception are not permitted.
It also applies when such a contract returns an invalid response from onERC721Received.
It should not be used for approval operations.
Parameters
receiver- Address of the invalid recipient.
ERC721InsufficientApproval
event ERC721InsufficientApproval(address operator, uint256 tokenId);Overview
A custom error concerning approval of a particular operator. Typically used during token transfers.
Details
Used when a token transfer lacks sufficient approval from the token owner for the operator.
Specifically, it applies when isApprovedForAll(owner, operator) is false and getApproved(tokenId) does not return operator.
Parameters
operator- Address of the operator for which approval is insufficient.
- `tokenId
- Associated token
tokenId.
- Associated token
ERC721InvalidApprover
event ERC721InvalidApprover(address approver);Overview
A custom error concerning the approver of a particular token. Typically used during token approval operations.
Details
Used when the token approver is invalid. For example, when approvals from the zero address are not permitted. It should not be used for token transfers.
Parameters
approver- Address of the invalid approver.
ERC721InvalidOperator
event ERC721InvalidOperator(address operator);Overview
A custom error concerning an invalid operator in an approval operation. Typically used during token approval operations.
Details
Used when a particular operator is invalid. For example, when an approval attempts to designate the zero address as an operator. It should not be used for token transfers.
Parameters
operator- Address of the invalid operator.
ERC1155
ERC1155InsufficientBalance
event ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);Overview
A custom error concerning the token sender's current balance. Typically used during token transfers.
Details
Used when the sender has an insufficient balance of the token identified by tokenId.
Parameters
sender- Address of the token sender.
balance- Current balance of the sender.
needed- Required balance.
tokenId- Associated token
tokenId.
- Associated token
ERC1155InvalidSender
event ERC1155InvalidSender(address sender);Overview
A custom error concerning the token sender. Typically used during token transfers.
Details
Used when the token sender is invalid. For example, when sending tokens from the zero address is not permitted. It should not be used for approval operations or balance and approval requirements.
Parameters
sender- Address of the invalid sender.
ERC1155InvalidReceiver
event ERC1155InvalidReceiver(address receiver);Overview
A custom error concerning the token recipient. Typically used during token transfers.
Details
Used when the token recipient is invalid.
For example, when transfers to the zero address or contracts that do not support ERC-1155 token reception are not permitted.
It also applies when such a contract returns an invalid response from onERC1155Received.
It should not be used for approval operations.
Parameters
receiver- Address of the invalid recipient.
ERC1155MissingApprovalForAll
event ERC1155MissingApprovalForAll(address operator, address owner);Overview
A custom error concerning approval of a particular operator. Typically used during token transfers.
Details
Used when a token transfer lacks appropriate approval between the token owner and the operator.
Specifically, it applies when isApprovedForAll(owner, operator) is false.
Parameters
operator- Address of the operator for which approval is insufficient.
owner- Address of the token owner.
ERC1155InvalidApprover
event ERC1155InvalidApprover(address approver);Overview
A custom error concerning the approver of a particular token. Typically used during token approval operations.
Details
Used when the token approver is invalid. For example, when approvals from the zero address are not permitted. It should not be used for token transfers.
Parameters
approver- Address of the invalid approver.
ERC1155InvalidOperator
event ERC1155InvalidOperator(address operator);Overview
A custom error concerning approval of a particular operator. Typically used during token approval operations.
Details
Used when a particular operator is invalid. For example, when an approval attempts to designate the zero address as an operator. It should not be used for token transfers.
Parameters
operator- Address of the invalid operator.
ERC1155InvalidArrayLength
event ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);Overview
A custom error indicating that the ids and values arrays have different lengths in a safeBatchTransferFrom operation.
Typically used during batch transfers.
Details
Used when the lengths of the ids (token IDs) and values (amounts) arrays do not match.
The numbers of IDs and values must correspond in a batch transfer.
Parameters
idsLength- Length of the
idsarray.
- Length of the
valuesLength- Length of the
valuesarray.
- Length of the
Parameter Glossary
| Parameter name | Description |
|---|---|
| sender | Address sending the tokens. |
| balance | Current balance of the account involved in the operation. |
| needed | Minimum amount required to perform the action. |
| receiver | Address receiving the tokens. |
| spender | Address that may operate on tokens without owning them. |
| allowance | Amount of tokens the spender is authorized to use. |
| approver | Address initiating an approval operation. |
| tokenId | Identifier of a token. |
| owner | Address of the current token owner. |
| operator | Same meaning as spender. |
| Length | Length of the array associated with the parameter. |
Adding errors
When adding errors to this EIP or introducing implementation-specific errors, such as extensions, follow the guidelines in the rationale to maintain consistency.
The proposal provides guidance on error content, structure, and naming conventions.
Following these guidelines makes new and implementation-specific errors consistent with existing errors, allowing developers and users to anticipate and understand them.
More consistent error handling improves quality and predictability across the ecosystem.
Rationale
The main purpose of standardizing token errors is to provide context when a failure occurs and make the error easier to understand. It is also important to use meaningful arguments where appropriate. This avoids lengthy error messages and keeps code size small.
Token error names therefore follow a basic grammatical structure based on standard token actions and the subjects associated with those actions.
The error name itself conveys the context or cause of a failure. Associating the error name with an action and its subject makes the failure clearer and easier to understand.
This approach produces consistent errors that help developers and users identify what went wrong during token operations. At the same time, it minimizes message length and code complexity.
Actions and subjects
Token error design should provide context about the failure and use a reasonable number of meaningful arguments. This conveys sufficient information while controlling code size.
Error names are therefore based on fundamental token actions and their associated subjects.
Two actions are particularly important in token operations.
Transfer
An operation that moves tokens from a sender to a recipient. The tokens may represent a fungible balance or a non-fungible token ID.
Approval
An operation in which an approver grants an operator some form of approval.
Considering these actions and subjects covers the kinds of problems that can arise in token operations. An error name identifies the subject involved in the failed action and adds an appropriate error prefix.
Even if particular token standards use different terms for a subject, the error name should follow the terminology of the corresponding standard.
Error prefixes
An error prefix indicates the specific type of failure. Developers can think of the prefix as describing why the error occurred.
Prefixes range from generic terms such as Invalid to more specific, quantity-related terms such as Insufficient.
The Invalid prefix, for example, indicates that something is not valid. The Insufficient prefix indicates that a quantity falls below a required amount. Error prefixes make the cause of a failure easier to understand and help developers and users identify problems quickly.
Domain
Token errors may use different arguments depending on the token type or domain.
However, when multiple errors have the same name but different arguments, the Solidity compiler can report a DeclarationError.
Consider the following example.
InsufficientApproval(address spender, uint256 allowance, uint256 needed);
InsufficientApproval(address operator, uint256 tokenId);When errors named InsufficientApproval have different arguments, as above, the compiler reports an error.
To avoid this problem, the proposal prefixes each error name with its token type or domain. The prefix combines the name of the ERC standard and its number.
For example:
ERC20InsufficientApproval(address spender, uint256 allowance, uint256 needed);
ERC721InsufficientApproval(address operator, uint256 tokenId);A domain prefix distinguishes errors belonging to different token standards and avoids name collisions.
Arguments
Choosing the arguments of a token error is important for conveying its context. Arguments should follow this order.
Who is involved in the error?
This identifies the entity involved in the failure.
For example, if an error concerns a particular address, such as address sender, include that address as an argument.
What failed?
This identifies the specific problem.
For example, if the token allowance is insufficient, include the current allowance, such as uint256 allowance.
Why did it fail?
Additional arguments may be needed to explain why an error occurred.
For example, include the required token amount, such as uint256 needed, to explain why an operation failed.
Following this order makes errors clear and helps developers and users understand their context.
Not every argument is necessary in every case, and some tokens require a tokenId.
The proposal generally places tokenId at the end as additional information.
Error grammar
Based on the preceding discussion, error names follow this grammar.
<Domain><ErrorPrefix><Subject>(<Arguments>);Domain (token type)
Indicates the type of token. Common examples are ERC-20, ERC-721, and ERC-1155, though other standards may also be considered. This part contains the name of a specific token standard.
ErrorPrefix (error prefix)
A prefix indicating the type or cause of an error. Common examples are Invalid and Insufficient, although other prefixes may apply depending on the circumstances.
Subject
Indicates the subject or participant associated with the error.
Common subjects include Sender, Receiver, Balance, Approver, Operator, and Approval.
Subject naming conventions may differ between token standards, so use the terminology appropriate for each standard.
Arguments
Arguments provide details about an error and explain why it occurred. They generally follow the order Who, What, and Why. Arguments can carry different information depending on the specific failure.
Backward Compatibility
Many deployed tokens primarily use revert strings in older implementations, relying on require rather than custom errors.
Tokens deployed using Solidity 0.8.4 or later may also inherit implementations that use revert strings.
This EIP cannot be retroactively enforced on existing non-upgradeable tokens. Such tokens generally follow similar conventions with small differences, such as adding or omitting domains, using different error prefixes, or adding similar subjects.
Upgradeable contracts, on the other hand, may be upgraded to implement this EIP.
Implementers and dapp developers supporting compliant tokens must also handle errors from non-compliant contracts and traditional revert strings.
They must remain flexible enough to handle errors raised by contracts that do not follow this EIP.
Reference Implementation
pragma solidity ^0.8.4;
/// @title Standard ERC20 Errors
/// @dev See https://eips.ethereum.org/EIPS/eip-20
/// https://eips.ethereum.org/EIPS/eip-6093
interface ERC20Errors {
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
error ERC20InvalidSender(address sender);
error ERC20InvalidReceiver(address receiver);
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
error ERC20InvalidApprover(address approver);
error ERC20InvalidSpender(address spender);
}
/// @title Standard ERC721 Errors
/// @dev See https://eips.ethereum.org/EIPS/eip-721
/// https://eips.ethereum.org/EIPS/eip-6093
interface ERC721Errors {
error ERC721InvalidOwner(address owner);
error ERC721NonexistentToken(uint256 tokenId);
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
error ERC721InvalidSender(address sender);
error ERC721InvalidReceiver(address receiver);
error ERC721InsufficientApproval(address operator, uint256 tokenId);
error ERC721InvalidApprover(address approver);
error ERC721InvalidOperator(address operator);
}
/// @title Standard ERC1155 Errors
/// @dev See https://eips.ethereum.org/EIPS/eip-1155
/// https://eips.ethereum.org/EIPS/eip-6093
interface ERC1155Errors {
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
error ERC1155InvalidSender(address sender);
error ERC1155InvalidReceiver(address receiver);
error ERC1155MissingApprovalForAll(address operator, address owner)
error ERC1155InvalidApprover(address approver);
error ERC1155InvalidOperator(address operator);
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}Security Considerations
There are no known signature hash collisions among the specified errors.
Tokens upgraded to implement this EIP may break assumptions in other systems that rely on revert strings.
Citation
Ernesto García (@ernestognw), Francisco Giordano (@frangio), Hadrien Croubois (@Amxx), "ERC-6093: Custom errors for commonly-used tokens [DRAFT]," Ethereum Improvement Proposals, no. 6093, December 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6093.
Conclusion
This article covered ERC-6093, which proposes standardized custom errors for ERC-20, ERC-721, and ERC-1155 tokens. I hope this explanation was helpful.
If you have questions, feel free to contact me via Twitter DM.
I also publish articles on the following platforms.


