# @fhenixprotocol/cofhe-errors 中文文档

规范地址：https://npmcn.com/package/%40fhenixprotocol/cofhe-errors/

版本：1\.0\.2
npm 元数据更新时间：2026-01-28T14:30:18.254Z
中文译文更新时间：2026-11-14T16:35:54.637Z
软件包许可：未声明

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40fhenixprotocol/cofhe-errors
原文对照：https://npmcn.com/package/%40fhenixprotocol/cofhe-errors/?lang=original
项目主页：https://github.com/FhenixProtocol/cofhe-contracts#readme
源码仓库：https://github.com/FhenixProtocol/cofhe-contracts

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：30.6 kB，5 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：0 个
- 首次发布：2025-12-29T13:40:01.034Z
- 最新版本发布：2026-01-28T14:30:17.974Z
- 近 30 天下载量：3602（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：3（近 12 个月 3 个）

## 中文简介

COFHE智能合同的错误定义和识别符

## 安装

```sh
npm install @fhenixprotocol/cofhe-errors
```

也可以使用：`pnpm add @fhenixprotocol/cofhe-errors`、`yarn add @fhenixprotocol/cofhe-errors`、`bun add @fhenixprotocol/cofhe-errors`

## README

# @fhenixprotocol/cofhe-errors (英语)

> **解码固态智能合同错误并立即解决"执行还原"消息**

[![npm version](https://img.shields.io/npm/v/@fhenixprotocol/cofhe-errors.svg)](https://www.npmjs.com/package/@fhenixprotocol/cofhe-errors) [![License](https://img.shields.io/npm/l/@fhenixprotocol/cofhe-errors.svg)](https://www.npmjs.com/package/@fhenixprotocol/cofhe-errors)

## 为什么是这个包?

### 问题: “ 执行还原” 出错

在与"团结"智能合约合作时,你可能遇到了加密错误消息,如:

```
Error: execution reverted: 0x118cdaa7
Transaction reverted without a reason string
execution reverted
```

这些错误令人沮丧,因为:

-   **不透明**:您只获得一个4字节错误选择器(例如, `0x118cdaa7`(中文(简体) )
-   **难于调试**: 没有可读错误信息
-   **耗时**: 合同代码或区块勘探者的人工查询
-   **中断 AI 助手流**: Claude Code, Cursor, GitHub 副驾驶等工具没有上下文无法帮助

### 解决方案:即时错误解码

此软件包提供 **即时, 人类可读错误解码** 为了你的团结合同。 它将选择者错误地映射到他们的全签名,名称和参数.

**不需要安装!** 使用 `npx` 以立即解码出错 :

```bash
npx cofhe-errors 0x118cdaa7
# Returns: OwnableUnauthorizedAccount(address)
```

## 里面有什么东西

此套件包含:

-   **53个自定义错误** 从 **13份智能合同**
-   带有参数类型的完整错误签名
-   原始合同资料
-   快速 CLI 搜索工具
-   程序化 JavaScript/ TypeScript API

### 覆盖错误

-   **ACL 阿拉伯法律联盟**: 8 个错误
-   **地址**: 1 出错
-   **常见**: 2 个错误
-   **ECDSA 数据交换系统**: 3 个错误
-   **ERC-1967UTIs (英语)**: 4个错误
-   **错误**: 4个错误
-   **同性恋**: 1 出错
-   **可升级**: 4个错误
-   **纯文本图集**: 1 出错
-   **保险箱**: 4个错误
-   **字符串**: 3 个错误
-   **任务管理器**: 16个错误
-   **UUPS 可升级**: 2 个错误

## QQ 快速启动

**不需要安装!** 使用 `npx` 立即运行 :

```bash
npx cofhe-errors 0x118cdaa7
```

### 可选: 安装供程序使用

只有在您需要导入代码中的错误数据库时才会安装 :

```bash
# NPM
npm install @fhenixprotocol/cofhe-errors

# Yarn
yarn add @fhenixprotocol/cofhe-errors

# PNPM
pnpm add @fhenixprotocol/cofhe-errors
```

## QQ 如何使用

### 命令行接口( CLI)

#### 解码出错选择器

当你看到"执行还原:0x..."

```bash
npx cofhe-errors 0x118cdaa7
```

**输出 :**

```
Name:      OwnableUnauthorizedAccount
Selector:  0x118cdaa7
Signature: OwnableUnauthorizedAccount(address)
Source:    ACL
Inputs:    address
```

#### 按名称搜索错误

当您知道部分错误名称时有用 :

```bash
npx cofhe-errors --name Permission
```

**输出 :**

```
0x4c40eccb PermissionInvalid_IssuerSignature (ACL)
0x8e143bf7 PermissionInvalid_RecipientSignature (ACL)
0xcbd3a966 PermissionInvalid_Disabled (ACL)
0xed0764a1 PermissionInvalid_Expired (ACL)
```

#### 列出所有已知错误

浏览完整错误数据库:

```bash
npx cofhe-errors --list
```

#### JSON 脚本输出

与您的工具和脚本整合 :

```bash
npx cofhe-errors --json 0x118cdaa7
```

**输出 :**

```json
{
  "name": "OwnableUnauthorizedAccount",
  "selector": "0x118cdaa7",
  "signature": "OwnableUnauthorizedAccount(address)",
  "source": "ACL",
  "inputs": ["account"],
  "inputTypes": ["address"]
}
```

### 程序化 API( JavaScript/ TypeScript)

在应用程序代码中使用 :

```javascript
const errors = require('@fhenixprotocol/cofhe-errors/errors.json');

// Find error by selector
const error = errors.find(e => e.selector === '0x118cdaa7');
console.log(`Error: ${error.name}`);
console.log(`Signature: ${error.signature}`);

// Search by name
const permissionErrors = errors.filter(e =>
  e.name.toLowerCase().includes('permission')
);

// Get all errors from a specific contract
const aclErrors = errors.filter(e => e.source === 'ACL');
```

### 类型脚本支持

错误. json 文件与 TypeScript 无缝:

```typescript
import errors from '@fhenixprotocol/cofhe-errors/errors.json';

interface SolidityError {
  name: string;
  selector: string;
  signature: string;
  source: string;
  inputs: string[];
  inputTypes: string[];
}

const error = errors.find(e => e.selector === '0x118cdaa7') as SolidityError;
```

## QQ 完整错误引用

### 错误数据库( 53 个错误)

| 选择器 | 名称 | 合同 | 签署 |
| --- | --- | --- | --- |
| `0x01d4fab6` | 无效的切换器 | 常见 | `InvalidHexCharacter(bytes1)` |
| `0x118cdaa7` | 非授权账户 | 可升级 | `OwnableUnauthorizedAccount(address)` |
| `0x1d15ae44` | 字符串无效地址格式 | 字符串 | `StringsInvalidAddressFormat()` |
| `0x1e4fbdf7` | 自有无效的奥纳 | 可升级 | `OwnableInvalidOwner(address)` |
| `0x24775e06` | SafeCast Coverflowed Uint To Int 安全控制系统 | 保险箱 | `SafeCastOverflowedUintToInt(uint256)` |
| `0x24cbcf36` | 无效的安全区 | 任务管理器 | `InvalidSecurityZone(int32,int32,int32)` |
| `0x2b0399d5` | 过多输入 | 任务管理器 | `TooManyInputs(string,uint256,uint256)` |
| `0x30dc9203` | 发件人无法被删除 | ACL 阿拉伯法律联盟 | `SenderCannotBeDelegateeAddress()` |
| `0x327269a7` | SafeCast 重叠下播 | 保险箱 | `SafeCastOverflowedIntDowncast(uint8,int256)` |
| `0x3809a243` | 直接全罗禁止 | ACL 阿拉伯法律联盟 | `DirectAllowForbidden(address)` |
| `0x42b01bce` | 缺少编译 | 错误 | `MissingPrecompile(address)` |
| `0x4c40eccb` | 权限无效 签名 | ACL 阿拉伯法律联盟 | `PermissionInvalid_IssuerSignature()` |
| `0x4c9c8ce3` | ERC1967 无效执行 | ERC-1967UTIs (英语) | `ERC1967InvalidImplementation(address)` |
| `0x4d13139e` | ACL 不允许 | 任务管理器 | `ACLNotAllowed(uint256,address)` |
| `0x52b50ae1` | 无效的Type或安全区 | 任务管理器 | `InvalidTypeOrSecurityZone(string)` |
| `0x62e77ba2` | ERC1967 无效Admin | ERC-1967UTIs (英语) | `ERC1967InvalidAdmin(address)` |
| `0x64ced0ec` | ERC1967 无效 Beacon | ERC-1967UTIs (英语) | `ERC1967InvalidBeacon(address)` |
| `0x67cf3071` | 无效的已复制输入 | 同性恋 | `InvalidEncryptedInput(uint8,uint8)` |
| `0x6dfcc650` | 安全控制重叠 UintDowncast | 保险箱 | `SafeCastOverflowedUintDowncast(uint8,uint256)` |
| `0x70cf6554` | 解密结果不准备 | 任务管理器 | `DecryptionResultNotReady(uint256)` |
| `0x7ba5ffb5` | 无效的符号 | 任务管理器 | `InvalidSigner(address,address)` |
| `0x884a0e9d` | 无效的输入类型 | 任务管理器 | `InvalidInputType(uint8,uint8)` |
| `0x8baa579f` | 无效的签名 | 任务管理器 | `InvalidSignature()` |
| `0x8e143bf7` | 允许无效 接收签名 | ACL 阿拉伯法律联盟 | `PermissionInvalid_RecipientSignature()` |
| `0x8f568bf8` | 安全区边界外 | 常见 | `SecurityZoneOutOfBounds(int32)` |
| `0x91b4b378` | 无效的输入功能 | 任务管理器 | `InvalidInputForFunction(string,uint8)` |
| `0x94e2737e` | 字符串无效Char | 字符串 | `StringsInvalidChar()` |
| `0x98e08ab0` | 随机功能不支持 | 任务管理器 | `RandomFunctionNotSupported()` |
| `0x9996b315` | 地址编码 | 地址 | `AddressEmptyCode(address)` |
| `0x9a84351c` | 无效的输入自动挂载 | 任务管理器 | `InvalidInputsAmount(string,uint256,uint256)` |
| `0xa8ce4432` | SafeCast 重叠输入 | 保险箱 | `SafeCastOverflowedIntToUint(int256)` |
| `0xa974a0fe` | 仅限隔离 | 任务管理器 | `OnlyAggregatorAllowed(address)` |
| `0xaa1d49a4` | UUPS 不支持的近似UUUID | UUPS 可升级 | `UUPSUnsupportedProxiableUUID(bytes32)` |
| `0xb06ebf3d` | 部署失败 | 错误 | `FailedDeployment()` |
| `0xb31612aa` | 无效的操作输入 | 任务管理器 | `InvalidOperationInputs(string)` |
| `0xb398979f` | ERC1967 无薪 | ERC-1967UTIs (英语) | `ERC1967NonPayable()` |
| `0xcabe5ce4` | 不支持类型 | 任务管理器 | `UnsupportedType(uint256)` |
| `0xcbd3a966` | 许可无效 已失效 | ACL 阿拉伯法律联盟 | `PermissionInvalid_Disabled()` |
| `0xcf479181` | 证据不足 | 错误 | `InsufficientBalance(uint256,uint256)` |
| `0xd0d25976` | 发件人不全数 | ACL 阿拉伯法律联盟 | `SenderNotAllowed(address)` |
| `0xd1860468` | 已授权 | ACL 阿拉伯法律联盟 | `AlreadyDelegated()` |
| `0xd6bda275` | 调用失败 | 错误 | `FailedCall()` |
| `0xd78bce0c` | ECDSA 无效签名S | ECDSA 数据交换系统 | `ECDSAInvalidSignatureS(bytes32)` |
| `0xd7e6bcf8` | 启动 | 可升级 | `NotInitializing()` |
| `0xd8aba367` | 无法使用 | 任务管理器 | `CofheIsUnavailable()` |
| `0xdce3ec0a` | 只有任务管理员全部放弃 | 纯文本图集 | `OnlyTaskManagerAllowed(address)` |
| `0xe07c8dba` | 授权UUPS 调用语句 | UUPS 可升级 | `UUPSUnauthorizedCallContext()` |
| `0xe22e27eb` | 字符串不足HexLength | 字符串 | `StringsInsufficientHexLength(uint256,uint256)` |
| `0xe6c4247b` | 无效的添加 | 任务管理器 | `InvalidAddress()` |
| `0xed0764a1` | 允许无效 已过期 | ACL 阿拉伯法律联盟 | `PermissionInvalid_Expired()` |
| `0xf645eedf` | ECDSA 无效签名 | ECDSA 数据交换系统 | `ECDSAInvalidSignature()` |
| `0xf92ee8a9` | 无效的初始化 | 可升级 | `InvalidInitialization()` |
| `0xfce698f7` | ECDSA 无效签名Length | ECDSA 数据交换系统 | `ECDSAInvalidSignatureLength(uint256)` |

## 常见案件

### 1\. 调试失败交易

```bash
# Your transaction failed with:
# Error: execution reverted: 0x118cdaa7

# Decode it instantly:
npx cofhe-errors 0x118cdaa7

# Output shows:
# Name: OwnableUnauthorizedAccount
# This means: The caller doesn't have ownership permissions
```

### 2\. 散装出错分析

```bash
# Get all errors from a specific contract
npx cofhe-errors --list | grep "ACL"

# Search for all permission-related errors
npx cofhe-errors --name Permission
```

### 3\. 监测错误和记录错误

```javascript
const errors = require('@fhenixprotocol/cofhe-errors/errors.json');

// Decode error from blockchain event
function decodeError(errorData) {
  const selector = errorData.slice(0, 10); // First 4 bytes
  const error = errors.find(e => e.selector === selector);

  if (error) {
    console.log(`Error: ${error.name}`);
    console.log(`Contract: ${error.source}`);
    console.log(`Signature: ${error.signature}`);
  }
}
```

### 4\. 文档和错误目录

为您的智能合同生成错误文档 :

```bash
npx cofhe-errors --list > CONTRACT_ERRORS.md
```

## AI 编码助理

此软件包包括 `AI.md` 包含AI助手(Claude Code, Cursor, GitHub Copilot等)的详细说明,说明调试工作流程中何时以及如何建议这个工具.

**快速引用 :** 当你看到 `execution reverted: 0x...`建议:

```bash
npx cofhe-errors <error-selector>
```

## QQ 错误选择器格式

固态自定义错误使用4字节选择器计算为:

```
selector = keccak256("ErrorName(type1,type2,...)").slice(0, 4)
```

**示例**

```solidity
error OwnableUnauthorizedAccount(address account);
```

成为:

-   签署: `OwnableUnauthorizedAccount(address)`
-   选择器 : `keccak256("OwnableUnauthorizedAccount(address)") = 0x118cdaa7...`
-   前4个字节 : `0x118cdaa7`

## 有关资源

-   [固态文档 - 自定义错误](https://docs.soliditylang.org/en/latest/contracts.html#errors)
-   [EIP-7930:自定义错误](https://eips.ethereum.org/EIPS/eip-7930)
-   [固态- 过分识别- 行动](https://github.com/FhenixProtocol/solidity-error-identifier-action) - GitHub 生成此软件包的动作

## 许可证

详情见LICENSE文件.

## 捐款

找到窃听器还是有什么建议? 请打开GitHub的一期!

* * *

**软件包版本 :** 1.0.2 联合国

**产生者:** [固态- 过分识别- 行动](https://github.com/FhenixProtocol/solidity-error-identifier-action)

**SEO 标记 :** 固态错误解码器 执行还原 智能合同出错 ethereum解码器 web3 错误处理 固态自定义出错 交易还原 错误选择器查询 区块链解码器 固态 ethereum 出错 智能合同 区块链 解码器 执行还原器 出错解码器 固态-errors,web3

## 常见问题

### @fhenixprotocol/cofhe-errors 是什么？

COFHE智能合同的错误定义和识别符

### 如何安装 @fhenixprotocol/cofhe-errors？

在项目目录运行 npm install @fhenixprotocol/cofhe-errors，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 cofhe-errors，可以用 npx cofhe-errors 直接运行。

### @fhenixprotocol/cofhe-errors 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/fhenixprotocol\_\_cofhe-errors 是否存在。

### @fhenixprotocol/cofhe-errors 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @fhenixprotocol/cofhe-errors 可以商用吗？

@fhenixprotocol/cofhe-errors 使用 未声明 许可。package\.json 没有声明许可证。没有许可证的代码默认保留全部权利，商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括，不构成法律意见，请以许可原文为准。

### @fhenixprotocol/cofhe-errors 的下载量有多少？

根据 npm 官方下载统计，@fhenixprotocol/cofhe-errors 在 2026/10/15 – 2026/11/13 这 30 天内被下载 3,602 次，日均约 120 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @fhenixprotocol/cofhe-errors 还在维护吗？

最新版本 1\.0\.2 发布于 2026/01/28（9 个月前）；至今共发布 3 个版本，其中过去 12 个月发布了 3 个；首次发布于 2025/12/29。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

