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.

This article covers ERC1066, a proposal that lets smart contract developers express detailed execution states, rather than simply success or failure, through common codes. This makes contract interactions and user feedback clearer and easier to automate.

This article translates, summarizes, and adds explanations to the specification linked below.

I also cover a range of other EIPs:

Overview

ERC1066 is a standard that introduces common status codes for smart contract execution results. Inspired by HTTP status codes, it lets different smart contracts return codes with shared meanings, making error handling, state management, and user-facing messages more systematic.

Smart contracts commonly respond to unsuccessful conditions by immediately calling revert (aborting execution). Alternatively, they may return only a Boolean true or false, making it difficult for developers and users to understand why an operation failed and how to respond. ERC1066 aims to improve interoperability, automation, and user experience by returning meaningful codes for different forms of success and failure.

These status codes can also be used alongside revert and revert-with-reason (rolling back with an explanation), providing flexible ways to handle exceptions and control execution flow. This makes it possible to distinguish types of failure, meanings of success, and execution transitions in greater detail and in a machine-readable form.

Motivation

ERC1066 was proposed in response to the limited information typically conveyed by smart contracts. When execution results in the EVM are expressed only through Boolean values or a simple revert, it is difficult to determine the nature of an error or the details of a state transition.

Status codes let a contract describe where execution reached, why it produced a particular result, and what that result was through a single code. Like HTTP 404 Not Found and 200 OK, predefined codes allow different parties to interpret execution results consistently.

Users can receive more specific error messages, which also helps with localization and user interface design. For example, using ERC1444 alongside status codes can provide user-facing descriptions associated with those codes.

See the following article for more on ERC1444.

[ERC1444] Localizing Smart Contract Error Messages

Developers can also write clearer tests by checking the status codes returned by individual branches of execution, helping with debugging and software quality. A shared set of codes also allows contracts to reuse common utilities and libraries, improving development efficiency.

Furthermore, smart contracts need a richer understanding of execution results to act autonomously. A bool or a simple revert offers limited information for making decisions, whereas status codes with well-defined meanings let contracts interpret the result and choose the next action.

Specification

ERC1066 defines a format for returning status codes from functions. Instead of representing a result as just true or false, a smart contract returns a meaningful byte value (for example, hex"01"), allowing callers to distinguish states more precisely.

With ERC1066, a status code may be returned on its own or in combination with other values. A function that only needs to communicate whether it succeeded can return the byte value alone. A function that also returns a result, such as a number or address, can return a tuple.

This allows smart contracts to communicate their state more meaningfully to external contracts and frontends. It also lets callers automatically choose an execution branch based on the return value or display a message that can be localized for the user.

For example, the following code checks whether a value is an integer and returns a status code.

javascript
function isInt(uint num) public pure returns (byte status) {
    return hex"01";
}

The following code attempts to safely increment counter, returning both the result and the status code. It returns hex"01" if the increment succeeds and hex"00" otherwise.

javascript
function safeIncrement(uint8 interval) public returns (byte status, uint8 newCounter) {
    uint8 updated = counter + interval;

    if (updated >= counter) {
        counter = updated;
        return (hex"01", updated);
    } else {
        return (hex"00", counter);
    }
}

Status code structure

ERC1066 defines smart contract status codes in a 16×16 matrix, using two hexadecimal digits. The high nibble (upper four bits) represents the category, and the low nibble (lower four bits) represents the state or reason. For example, 0x01 means success (0x01) in category 0x0 (Generic).

This design allows smart contracts to classify execution results unambiguously and in a machine-readable way, strengthening their interfaces with other contracts and external systems. The codes are organized into multiple categories, with more detailed states represented within each category.

0x0* Generic

This category defines the most fundamental codes, including basic success and failure statuses. Even when no other category applies, these codes can communicate the basic result.

Code Description
0x00 Failure
0x01 Success
0x02 Waiting for another party
0x03 Request accepted
0x04 Below minimum or insufficient
0x05 Recipient action required
0x06 Above maximum
0x07 Reserved
0x08 Duplicate, unnecessary, or not applicable
0x09–0x0E Reserved
0x0F Information or metadata

0x1* Permission & Control

This category provides codes related to access control and state-machine behavior. For example, it represents control-flow conditions such as an operation being disallowed or permission being required.

Code Description
0x10 Disallowed or stopped
0x11 Allowed or ready to proceed
0x12 Waiting for another party to grant permission
0x13 Permission requested
0x14 Unsafe from a security standpoint
0x15 Your permission is required, or a request to proceed
0x16 Revoked or forbidden
0x17 Reserved
0x18 Not applicable in the current state
0x19–0x1E Reserved
0x1F Metadata about permissions or control conditions

0x2* Find, Inequalities & Range

This category represents operations such as searching for values, checking matches and mismatches, and checking ranges. It applies to use cases such as order matching and database searches.

Code Description
0x20 Not found, no match, or out of range
0x21 Found, matched, or within range
0x22 Waiting for a match
0x23 Match request sent
0x24 Below the lower bound, or underflow
0x25 Match requested
0x26 Above the upper bound, or overflow
0x27 Reserved
0x28 Duplicate, conflict, or collision
0x29–0x2E Reserved
0x2F Metadata or additional information about a match

0x3* Negotiation & Governance

This category represents states in transaction workflows involving consensus, negotiation, and voting. It is used to express multistep processes within smart contracts, such as proposals, agreement, disagreement, and waiting for votes. The other party need not be a single person; the design also accounts for multiple actors.

Code Description
0x30 Sender disagrees or votes no
0x31 Sender agrees or votes yes
0x32 Waiting for ratification
0x33 Proposal submitted or vote cast
0x34 Quorum not reached
0x35 Recipient ratification required
0x36 Proposal or voting limit reached
0x37 Reserved
0x38 Already voted
0x39–0x3E Reserved
0x3F Information about negotiation rules or participants

0x4* Availability & Time

This category represents the temporal availability of a service or action: when it is available. It allows contracts to express pauses, delays, queues, and expiration at the contract level.

Code Description
0x40 Unavailable
0x41 Available
0x42 Paused
0x43 Queued
0x44 Not yet available
0x45 Waiting for your response or availability
0x46 Expired
0x47 Reserved
0x48 Already executed
0x49–0x4E Reserved
0x4F Availability rules or information (such as start or end times)

0x5* Tokens, Funds & Finance

This category defines financial states such as asset transfers, settlement, and pending payments. It is designed to distinguish statuses involving funds in detail, including token transfers, insufficient funds, and escrow.

Code Description
0x50 Transfer failed
0x51 Transfer succeeded
0x52 Waiting for payment from another party
0x53 On hold or in escrow
0x54 Insufficient funds
0x55 Funds requested
0x56 Transfer amount exceeds limit
0x57 Reserved
0x58 Funds not required
0x59–0x5E Reserved
0x5F Token or financial information

0x6*–0x9* Undefined Categories (TBD)

The ranges from 0x6* through 0x9* are currently undefined and reserved for future extensions. These codes should not currently be used; their meanings are expected to be defined in future extensions to ERC1066 or other proposals.

0xA* Application-Specific Codes

This category provides codes for states specific to an application or domain. The specification defines only broad meanings, allowing implementers to add more detailed meanings appropriate to their contracts. However, those definitions need to remain consistent with the underlying intent of the category.

Code Description
0xA0 Application-specific failure
0xA1 Application-specific success
0xA2 Application-specific wait for another party
0xA3 Application-specific acceptance
0xA4 Below application-specific requirements
0xA5 Application-specific recipient action required
0xA6 Application-specific expiration or upper limit
0xA7 Reserved
0xA8 Application-specific non-applicability
0xA9–0xAE Reserved
0xAF Application-specific metadata or additional information

0xB*–0xD* Undefined Categories (TBD)

The ranges 0xB*, 0xC*, and 0xD* are also undefined and reserved for future extensions. Because the specification has not yet assigned meanings to these codes, arbitrary use is discouraged.

0xE* Encryption, Identity & Proofs

This category represents states related to cryptographic operations and identity verification, such as signing, decryption, authentication, and key usage. It applies to application security and identity-based access control.

In particular, 0xEF is reserved for conveying detailed metadata, such as signature schemes or cryptographic algorithms.

Code Description
0xE0 Decryption failed
0xE1 Decryption succeeded
0xE2 Waiting for another party to provide a signature or key
0xE3 Signed
0xE4 Unsigned or untrusted
0xE5 Signature required
0xE6 Key or signature known to be exposed or compromised
0xE7 Reserved
0xE8 Already signed or not encrypted
0xE9–0xEE Reserved
0xEF Cryptography, identity, or proof metadata (such as methods or operations)

0xF* Off-Chain

This category lets smart contracts communicate states relating to off-chain operations. In ERC1066, 0xF* is general-purpose, like 0x0* (Generic). It primarily communicates what happened off-chain or what is being awaited.

For example, on-chain logic can return an explicit status indicating that the frontend is waiting for a user signature or that an operation involving an external API has begun. This makes it easier for smart contracts to coordinate with off-chain systems and improves feedback for users and developers.

0xFF is reserved for off-chain details (operations or metadata) and is intended to accompany descriptions of particular off-chain processes.

Code Description
0xF0 Off-chain operation failed
0xF1 Off-chain operation succeeded
0xF2 Waiting for off-chain operation to finish
0xF3 Off-chain operation started
0xF4 Unable to connect to off-chain service
0xF5 Off-chain action required
0xF6 Off-chain deadline or upper limit reached
0xF7 Reserved
0xF8 Duplicate off-chain request
0xF9–0xFE Reserved
0xFF Off-chain information or metadata

Complete matrix (16×16 grid)

ERC1066 organizes the full status code space into a 16×16 structure: category (upper four bits) × reason (lower four bits). The complete structure is shown below.

0x0* General 0x1* Permission & Control 0x2* Find/Range 0x3* Governance 0x4* Time/Availability 0x5* Finance 0x6*–0xD* Reserved 0xE* Encryption 0xF* Off-Chain
0x*0 0x00 Failure 0x10 Disallowed 0x20 Not Found 0x30 Disagrees 0x40 Unavailable 0x50 Transfer Failed [reserved] 0xE0 Decrypt Failure 0xF0 Off-Chain Failure
0x*1 0x01 Success 0x11 Allowed 0x21 Found 0x31 Agrees 0x41 Available 0x51 Transfer Success [reserved] 0xE1 Decrypt Success 0xF1 Off-Chain Success
0x*2 0x02 Awaiting Others 0x12 Await Permission 0x22 Awaiting Match 0x32 Awaiting Ratification 0x42 Paused 0x52 Awaiting Payment [reserved] 0xE2 Awaiting Signatures 0xF2 Awaiting Off-Chain
0x*3 0x03 Accepted 0x13 Permission Requested 0x23 Match Sent 0x33 Offer Sent 0x43 Queued 0x53 Escrow [reserved] 0xE3 Signed 0xF3 Off-Chain Started
0x*4 0x04 Lower Limit 0x14 Insecure 0x24 Underflow 0x34 Quorum Not Reached 0x44 Not Yet Available 0x54 Insufficient Funds [reserved] 0xE4 Untrusted 0xF4 Off-Chain Unreachable
0x*5 0x05 Action Required 0x15 Needs Permission 0x25 Match Request 0x35 Ratification Requested 0x45 Awaiting You 0x55 Funds Requested [reserved] 0xE5 Signature Required 0xF5 Off-Chain Action Req.
0x*6 0x06 Upper Limit 0x16 Revoked 0x26 Overflow 0x36 Vote Limit Reached 0x46 Expired 0x56 Volume Exceeded [reserved] 0xE6 Compromised 0xF6 Off-Chain Expired
0x*7 [reserved] [reserved] [reserved] [reserved] [reserved] [reserved] [reserved] [reserved] [reserved]
0x*8 0x08 Duplicate 0x18 Not Applicable 0x28 Conflict 0x38 Already Voted 0x48 Already Done 0x58 Not Required [reserved] 0xE8 Already Signed 0xF8 Duplicate Off-Chain
0x*9 [reserved] [reserved] [reserved] [reserved] [reserved] [reserved] [reserved] [reserved] [reserved]
0x*A [reserved] [reserved] [reserved] [reserved] [reserved] [reserved] [reserved] [reserved] [reserved]
0x*F 0x0F Metadata 0x1F Permission Info 0x2F Match Info 0x3F Governance Info 0x4F Time Info 0x5F Finance Info [reserved] 0xEF Crypto Meta 0xFF Off-Chain Meta

Example: improving a function with status codes

Returning a bool from a smart contract function does not explain why execution failed or what the particular state was. ERC1066 introduces status codes for such cases so that external callers can interpret richer information.

The following examples compare a conventional function returning a bool with an improved version that returns a status code.

Before: conventional function

js
uint256 private startTime;
mapping(address => uint) private counters;

function increase() public returns (bool _available) {
    if (now < startTime && counters[msg.sender] == 0) {
        return false;
    }

    counters[msg.sender] += 1;
    return true;
}

This function returns a bool indicating whether the user counter was incremented, but it does not explain why the operation failed. A return value of false does not distinguish the restriction imposed by startTime from that imposed by counters[msg.sender].

After: improved function

js
function increase() public returns (byte _status) {
    if (now < start) { return hex"44"; } // Not yet available
    if (counters[msg.sender] == 0) { return hex"10"; } // Disallowed

    counters[msg.sender] += 1;
    return hex"01"; // Success
}

With this change, the caller can respond to each condition individually.

  • 0x44: "Not Yet Available"
  • 0x10: "Disallowed"
  • 0x01: "Success"

This makes it possible to distinguish failure causes and improve UI messages and retry strategies.

Sequence diagram examples using status codes

Example 1: DEX purchase flow

In this sequence diagram, a buy() request is sent to a DEX, and different status codes are returned depending on the current state.

sequenceDiagram
  participant AwesomeCoin
  participant DEX
  participant TraderBot

  TraderBot->>DEX: buy(AwesomeCoin)
  DEX-->>AwesomeCoin: buy()
  AwesomeCoin->>DEX: Status [0x44] (Not yet available)
  DEX-->>TraderBot: Status [0x44]

  TraderBot->>DEX: isDoneYet()
  DEX-->>TraderBot: Status [0x44]

  AwesomeCoin->>DEX: Status [0x41] (Available)
  DEX-->>TraderBot: Status [0x41]

  TraderBot->>DEX: buy()
  DEX-->>AwesomeCoin: buy()
  AwesomeCoin->>DEX: Status [0x31] (Other party agreed)
  DEX-->>TraderBot: Status [0x31]

The status codes clearly express states such as not yet available for purchase (0x44), available for purchase (0x41), and agreement from another participant (0x31).

Example 2: token validation flow

Multiple contracts work together to determine whether a buyer is eligible to purchase tokens.

sequenceDiagram
  participant Buyer
  participant RegulatedToken
  participant TokenValidator
  participant IDChecker
  participant SpendLimiter

  Buyer->>RegulatedToken: buy()
  RegulatedToken->>TokenValidator: check()
  TokenValidator->>IDChecker: check()
  IDChecker-->>TokenValidator: Status [0x10] (Disallowed)
  TokenValidator-->>RegulatedToken: Status [0x10]
  RegulatedToken-->>Buyer: revert()

  Note over Buyer: After the identity information is updated...

  Buyer->>RegulatedToken: buy()
  RegulatedToken->>TokenValidator: check()
  TokenValidator->>IDChecker: check()
  IDChecker-->>TokenValidator: Status [0x11] (Allowed)
  TokenValidator->>SpendLimiter: check()
  SpendLimiter-->>TokenValidator: Status [0x11]
  TokenValidator-->>RegulatedToken: Status [0x11]
  RegulatedToken-->>Buyer: Status [0x01] (Success)

This example uses codes such as 0x10 (Disallowed) and 0x11 (Allowed) for successive access-control and limit checks, choosing the next action based on each result.

Additional considerations

Encoding and byte structure

A status code is represented as a byte (bytes1), with the upper four bits indicating the category and the lower four bits indicating the reason. For example, 0x01 means success (0x1) in the Generic category (0x0), while 0x10 means disallowed (0x0) in the Control category (0x1).

Even codes are treated as blocking states (the user cannot proceed freely) and odd codes as non-blocking states (the user can proceed freely), enabling simple branching with a check such as status % 2 == 1.

bytes1 is also compact, interoperates readily with uint8, and is suitable for conversions from an enum, making it an efficient representation.

Comparison with alternatives

Other approaches, including uint8 and bytes32, were considered, but each has drawbacks.

Although uint8 provides readability similar to HTTP status codes, it lacks the visual clarity of the two-digit hexadecimal category structure (the 16×16 matrix). Packing multiple codes into bytes32 is appealing in theory, but it complicates interpretation and can lead to meaningless combinations (for example, containing both 0x00 and 0x01).

Placing a single byte first in the return values is therefore the simplest approach and offers good compatibility.

Compatibility with multiple return values

A status code is typically returned as the first of multiple return values. This makes the meaning of the returned values easier to determine, much like an HTTP response header or a tagged tuple in a BEAM language.

Human-readable categories

Developers do not need to memorize all 256 codes: organizing them by category and reason reduces cognitive load considerably. For example, 0x10 (Disallowed) and 0x11 (Allowed) are contrasting states in the same category, while 0x04 (below minimum) and 0x24 (below the lower bound) share a reason.

The structure is designed to help developers become comfortable working directly with hexadecimal values without relying on a helper enum.

Localization (integration with ERC1444)

ERC1066 is designed with the translation of codes into human-readable messages in mind. Translation itself is delegated to the separate proposal ERC1444, which provides descriptions associated with codes and support for multiple languages.

Extensibility and application support

0xA* is reserved for application-specific status codes, allowing individual contracts and systems to define codes appropriate to their needs. If 256 codes prove insufficient in the future, extension to an array structure such as bytes1[] is also envisioned.

Consistency with the EVM

The EVM already uses 0x00 (failure) and 0x01 (success) as transaction status codes. ERC1066 is consistent with these meanings and is designed so that it could eventually be extended to status representations at the EVM level.

Undefined code space and its purpose

As with HTTP status codes, ERC1066 leaves many code ranges undefined. These gaps are intentional, providing room for future use cases and allowing the standard to evolve.

More than error codes

ERC1066 is not merely a way to record errors. It provides a common language for states, encompassing inter-contract communication, protocol design, and communication across off-chain operations.

Just as 200 OK and 201 Created have different meanings in HTTP, 0x01 (success) and 0x03 (accepted) convey different meanings even though both indicate success. This gives smart contracts a richer vocabulary for coordination.

Coexistence with revert

ERC1066 is compatible with revert-with-reason; the two approaches are not mutually exclusive. Reverting with a common code can make it easier to identify errors during debugging. Combining this approach with ERC1444 can also automatically interpret the code in a human-readable language for users.

Nibble order and readability

The order of the category (high nibble) and reason (low nibble) does not matter to machine processing, but the current order is designed to provide a natural classification for humans. Although this differs from HTTP, it becomes intuitive with familiarity.

Short forms and computational efficiency

hex"01" can be treated as 1, making conversion to and from integers straightforward. Operations within a particular category (for example, the 0x10 family for authentication and verification) can also construct codes efficiently using the category prefix.

Here is one example.

js
byte constant prefix = hex"10";

if (now >= deadline)  { return prefix | 5; } // Needs your permission
if (whitelist[_user]) { return prefix | 1; } // Allowed
return prefix; // Default: Disallowed

These bitwise operations allow a contract to return meaningful codes without unnecessary conditional branches.

Converting between an enum and application-specific codes

If application-specific states (such as Sleep) are defined using an enum, a helper for converting them into status codes can be written concisely.

js
enum Sleep {
    Awake,
    Asleep,
    BedOccupied,
    WindingDown
}

function appCode(Sleep _state) returns (byte code) {
    return byte(160 + _state); // 160 = 0xA0 (application-specific category)
}

Alternatively, the code can be generated using an expression as follows.

js
function appCode(Sleep _state) returns (byte code) {
    return byte((16 * _state) + 10); // 10 = 0xA
}

This combines integration with enum values and gas efficiency.

Citation

Brooklyn Zelenka (@expede), Tom Carchrae (@carchrae), Gleb Naumenko (@naumenkogs), "ERC-1066: Status Codes [DRAFT]," Ethereum Improvement Proposals, no. 1066, May 2018. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-1066.

Conclusion

This article covered ERC1066, which proposes a shared code system for describing detailed smart contract execution states beyond success and failure, making interactions between contracts and feedback to users clearer and easier to automate. I hope this explanation was helpful.

If you have questions, feel free to contact me via Twitter DM:

Twitter @cardene777

You can also find my other articles on the following platforms:

https://chaldene.net/