# ErrorExplainer: Automated Extraction of Error Contexts from Smart Contracts
## 1 Introduction  
No one explains users' failures in Web3. As cryptocurrencies gain adoption across financial services and other industries, Web3 has evolved to encompass applications ranging from Decentralized Finance (DeFi) to social networks. However, the user experience remains one of the most challenging issues in Web3 [1]. The problem becomes more severe when users encounter errors while managing crypto-assets or interacting with smart contracts. A recent study [2] found that existing Web3 clients, i.e., wallet software, seldom inform users about the reason for failed operations. Delivering a satisfactory user experience in this environment is challenging. When managing assets on the blockchain or using decentralized applications (dApps), users interact directly with smart contracts deployed on-chain. Smart contracts were initially designed with minimal functionality to limit complexity and cost. Thus, providing user-friendly information has never been a primary concern for developers. An Ethereum tutorial [3] even recommends replacing descriptive error messages with symbolic abbreviations to save gas. Web3 services remain error-prone and unfamiliar to users; users must understand the basics of public-key cryptography to use their assets and, when transactions fail, grasp whatever error data are returned. However, error messages from smart contracts are notstandardized and are frequently human-unreadable. For example, Table 1 lists several revert cases (i.e., error conditions) defined in the ERC-20 standard [4], the most widely adopted token interface. Among the ERC-20 interface functions, the transfer function is specified to emit a Transfer event upon success and to define two error conditions (insufficient balance or a zero recipient address), without specifying any error message. This lack of standardization has led developers to use inconsistent error messages. For the ERC-20 error case where a recipient address is zero, the Open-Zeppelin implementation of IERC-20 reverts with the binary-encoded code object ERC20 InvalidReceiver(address(0)), while other real-world smart contracts in the SC-Bench dataset [5] show at least three alternative outputs for the same condition: (1) a literal string \"ERC20: transfer to the zero address\", (2) an empty error message, or (3) no revert at all. To address this problem, a user-side solution is needed. Because smart contracts are immutable once deployed, changing them with standardized error messages is infeasible even for upgradable designs. Therefore, we propose ErrorExplainer, a client-side framework that automatically reconstructs error contexts to help users understand errors even with non-standardized error messages. ErrorExplainer leverages a characteristic of the Web3 ecosystem: the source code of most deployed contracts is published in verified form on explorers, such as Etherscan [6]. By locating the statement that triggered a given revert, the framework extracts structured facts, including the error condition and the origin (i.e., the enclosing function), and presents them to users. Additionally, users can query Large Language Models (LLMs) with the structured information to obtain natural-language explanations of their failed operations. Table 2 shows an example of the raw data returned to the user versus the enriched error context provided by ErrorExplainer. For a failed transfer caused by insufficient balance, the user can receive only a binary-encoded error message. At the same time, ErrorExplainer provides more critical information to understand the error, such as the function, error condition, and code snippet responsible for the error.