# @ethereum-sourcify/bytecode-utils

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

Latest version **1.6.2** (published 2026-08-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ethereum-sourcify/bytecode-utils
pnpm add @ethereum-sourcify/bytecode-utils
yarn add @ethereum-sourcify/bytecode-utils
bun add @ethereum-sourcify/bytecode-utils
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.6.2 |
| Published | 2026-08-20 |
| First published | 2022-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.0.0 |
| Dependencies | 5 |
| Unpacked size | 57.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 950 |
| Maintainers | ethereumci, chriseth |
| Keywords | sourcify, ethereum, cbor, contract, smart-contract, metadata, solidity, ipfs |

## Links

- npm: https://www.npmjs.com/package/@ethereum-sourcify/bytecode-utils
- Repository: https://github.com/argotorg/sourcify
- Homepage: https://github.com/argotorg/sourcify#readme
- Issues: https://github.com/argotorg/sourcify/issues
- npm.io page: https://npm.io/package/@ethereum-sourcify/bytecode-utils

## Dependencies (5)

- [bs58](https://npm.io/package/bs58.md) 6.0.0
- [base-x](https://npm.io/package/base-x.md) 5.0.1
- [cbor-x](https://npm.io/package/cbor-x.md) 1.6.4
- [ethers](https://npm.io/package/ethers.md) 6.17.0
- [semver](https://npm.io/package/semver.md) 7.8.5

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.6.2 (latest) — 2026-08-20
- 1.6.1 — 2026-07-06
- 1.6.0 — 2026-06-16
- 1.5.3 — 2026-05-27
- 1.5.2 — 2026-05-21
- 1.5.1 — 2026-05-06
- 1.5.0 — 2026-04-14
- 1.4.0 — 2026-03-30
- 1.3.22 — 2026-03-17
- 1.3.21 — 2026-03-03
- 1.3.20 — 2026-01-20
- 1.3.19 — 2026-01-07
- 1.3.18 — 2025-12-15
- 1.3.17 — 2025-11-19
- 1.3.16 — 2025-11-04
- … 31 more at https://npm.io/package/@ethereum-sourcify/bytecode-utils/versions

## README

# bytecode-utils

Decode the [CBOR encoded data](https://docs.soliditylang.org/en/latest/metadata.html#encoding-of-the-metadata-hash-in-the-bytecode) at the end of an Ethereum contract's bytecode.

## Install

```
yarn add @ethereum-sourcify/bytecode-utils
```

## Usage

### Solidity Contracts

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

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

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

**Result example**

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

### Vyper Contracts

```ts
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**

```json
{
  "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": [...]}]`

---
_Source: https://npm.io/package/@ethereum-sourcify/bytecode-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
