Skip to main content

Overview

When working with Solidity smart contracts, you’ve probably encountered cryptic error messages like:
Error: execution reverted: 0x118cdaa7
Transaction reverted without a reason string
execution reverted
These errors are frustrating because you only get a 4-byte error selector (e.g., 0x118cdaa7) with no human-readable message. The @fhenixprotocol/cofhe-errors package provides instant, human-readable error decoding for CoFHE smart contracts.

What's Inside

  • 53 custom errors from 13 smart contracts
  • Complete error signatures with parameter types
  • Source contract information
  • Fast CLI lookup tool
  • Programmatic JavaScript/TypeScript API

Quick Start

No installation required! Use npx to decode errors immediately:
npx cofhe-errors 0x118cdaa7
Output:
Name:      OwnableUnauthorizedAccount
Selector:  0x118cdaa7
Signature: OwnableUnauthorizedAccount(address)
Source:    ACL
Inputs:    address

Installation (Optional)

Only install if you need to import the error database programmatically in your code:
npm install @fhenixprotocol/cofhe-errors

CLI Usage

Decode an Error Selector

When you see “execution reverted: 0x…”, decode it instantly:
npx cofhe-errors 0x118cdaa7

Search Errors by Name

Find errors when you know part of the error name:
npx cofhe-errors --name Permission
Output:
0x4c40eccb PermissionInvalid_IssuerSignature (ACL)
0x8e143bf7 PermissionInvalid_RecipientSignature (ACL)
0xcbd3a966 PermissionInvalid_Disabled (ACL)
0xed0764a1 PermissionInvalid_Expired (ACL)

List All Known Errors

Browse the complete error database:
npx cofhe-errors --list

JSON Output

Get JSON output for scripting and automation:
npx cofhe-errors --json 0x118cdaa7
Output:
{
  "name": "OwnableUnauthorizedAccount",
  "selector": "0x118cdaa7",
  "signature": "OwnableUnauthorizedAccount(address)",
  "source": "ACL",
  "inputs": ["account"],
  "inputTypes": ["address"]
}

Programmatic API

JavaScript/TypeScript Usage

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');

TypeScript with Types

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;

Error Monitoring Example

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}`);
  }
}

Error Coverage

The package includes errors from the following contracts:
ContractError Count
TaskManager16
ACL8
SafeCast4
ERC1967Utils4
Errors4
Ownable2StepUpgradeable4
ECDSA3
Strings3
Common2
UUPSUpgradeable2
Address1
FHE1
PlaintextsStorage1

How Error Selectors Work

Solidity custom errors use a 4-byte selector computed as:
selector = keccak256("ErrorName(type1,type2,...)").slice(0, 4)
Example:
error OwnableUnauthorizedAccount(address account);
Becomes:
  • Signature: OwnableUnauthorizedAccount(address)
  • Selector: keccak256("OwnableUnauthorizedAccount(address)") = 0x118cdaa7...
  • First 4 bytes: 0x118cdaa7

Next Steps