@ethereum-sourcify/bytecode-utils

中文文档
1.7.0发布于 2026/11/03MITTypeScriptESM + CJS近 30 天下载 4万

Decode the CBOR encoded data at the end of an Ethereum contract's bytecode.

原始使用文档
文档目录4 节
  1. Install
  2. Usage
  3. Solidity Contracts
  4. Vyper Contracts

bytecode-utils

Decode the CBOR encoded data at the end of an Ethereum contract's bytecode.

Install

yarn add @ethereum-sourcify/bytecode-utils

Usage

Solidity Contracts

import { decode, AuxdataStyle } from "@ethereum-sourcify/bytecode-utils";

const bytecodeRaw = "0x60806040526004361061003f5760003560e01...7265206c656e677468a2646970667358221220dceca8706b29e917dacf25fceef95acac8d90d765ac926663ce4096195952b6164736f6c634300060b0033"

// For Solidity contracts
decode(bytecodeRaw, AuxdataStyle.SOLIDITY);

Result example

{
  "ipfs": "QmdD3hpMj6mEFVy9DP4QqjHaoeYbhKsYvApX1YZNfjTVWp",
  "solcVersion": "0.6.11",
  "experimental": true,
  "bzzr0": "...",
  "bzzr1": "..."
}

Vyper Contracts

import { decode, getAuxdataStyle } from "@ethereum-sourcify/bytecode-utils";

const vyperBytecodeRaw = "0x..."; // Your Vyper contract bytecode

// For Vyper contracts
decode(vyperBytecodeRaw, getAuxdataStyle("Vyper", "0.4.1"));

Result example

{
  "integrity": "...",
  "runtimeSize": 1234,
  "dataSizes": [32, 64, 128],
  "immutableSize": 256,
  "vyperVersion": "0.3.10"
}

Vyper Version Compatibility Notes

Different Vyper compiler versions use different auxdata formats:

  • <0.3.4: no CBOR auxdata
  • 0.3.4: CBOR map {"vyper": [0, 3, 4]} with no length footer
  • 0.3.5-0.3.9: CBOR map {"vyper": [...]} plus length footer
  • 0.3.10-0.4.0: CBOR array [runtimeSize, dataSizes, immutableSize, {"vyper": [...]}]
  • >=0.4.1: CBOR array [integrity, runtimeSize, dataSizes, immutableSize, {"vyper": [...]}]

版本与发布记录

@ethereum-sourcify/bytecode-utils 共发布 49 个版本,首次发布于 2022/11/11;过去 12 个月发布了 17 个版本。

版本发布日期距今
1.7.0latest2026/11/0310 天前
1.6.42026/10/2123 天前
1.6.32026/10/051 个月前
1.6.22026/08/202 个月前
1.6.12026/07/064 个月前
1.6.02026/06/164 个月前

关于 @ethereum-sourcify/bytecode-utils 的常见问题

@ethereum-sourcify/bytecode-utils 是什么?

Decode the CBOR encoded data at the end of an Ethereum contract's bytecode.

如何安装 @ethereum-sourcify/bytecode-utils?

在项目目录运行 npm install @ethereum-sourcify/bytecode-utils,或使用 pnpm add / yarn add / bun add。

@ethereum-sourcify/bytecode-utils 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ethereum-sourcify/bytecode-utils 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@ethereum-sourcify/bytecode-utils 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js v26.10.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@ethereum-sourcify/bytecode-utils 可以商用吗?

@ethereum-sourcify/bytecode-utils 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ethereum-sourcify/bytecode-utils 的下载量有多少?

根据 npm 官方下载统计,@ethereum-sourcify/bytecode-utils 在 2026/10/14 – 2026/11/12 这 30 天内被下载 40,204 次,日均约 1,340 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ethereum-sourcify/bytecode-utils 还在维护吗?

最新版本 1.7.0 发布于 2026/11/03(10 天前);至今共发布 49 个版本,其中过去 12 个月发布了 17 个;首次发布于 2022/11/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。