# ethereumjs-util

> A collection of utility functions for Ethereum

Latest version **7.1.5** (published 2022-06-03) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install ethereumjs-util
pnpm add ethereumjs-util
yarn add ethereumjs-util
bun add ethereumjs-util
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 7.1.5 |
| Published | 2022-06-03 |
| First published | 2015-01-28 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=10.0.0 |
| Dependencies | 5 |
| Unpacked size | 302.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2755 |
| Author | mjbecze |
| Maintainers | holgerd77, evertonfraga, ralxz, null_radix, axic, jwasinger |
| Keywords | ethereum, utilities, utils |

## Links

- npm: https://www.npmjs.com/package/ethereumjs-util
- Repository: https://github.com/ethereumjs/ethereumjs-monorepo
- Homepage: https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/util#readme
- Issues: https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aissue+label%3A%22package%3A+util%22
- npm.io page: https://npm.io/package/ethereumjs-util

## Dependencies (5)

- [rlp](https://npm.io/package/rlp.md) ^2.2.4
- [bn.js](https://npm.io/package/bn.js.md) ^5.1.2
- [create-hash](https://npm.io/package/create-hash.md) ^1.1.2
- [@types/bn.js](https://npm.io/package/@types/bn.js.md) ^5.1.0
- [ethereum-cryptography](https://npm.io/package/ethereum-cryptography.md) ^0.1.3

## Recent versions

- 7.1.5 (latest) — 2022-06-03
- 7.1.4 — 2022-02-01
- 7.1.3 — 2021-10-14
- 7.1.2 — 2021-09-29
- 7.1.1 — 2021-09-27
- 7.1.0 — 2021-07-08
- 7.0.10 — 2021-04-01
- 7.0.9 — 2021-03-04
- 7.0.8 — 2021-02-02
- 7.0.7 — 2020-10-19
- 7.0.6 — 2020-10-08
- 7.0.5 — 2020-09-10
- 7.0.4 — 2020-08-04
- 4.5.1 — 2020-07-16
- 5.2.1 — 2020-07-16
- … 69 more at https://npm.io/package/ethereumjs-util/versions

## README

# ethereumjs-util

[![NPM Package][util-npm-badge]][util-npm-link]
[![GitHub Issues][util-issues-badge]][util-issues-link]
[![Actions Status][util-actions-badge]][util-actions-link]
[![Code Coverage][util-coverage-badge]][util-coverage-link]
[![Discord][discord-badge]][discord-link]

A collection of utility functions for Ethereum. It can be used in Node.js and in the browser with [browserify](http://browserify.org/).

# INSTALL

`npm install ethereumjs-util`

# USAGE

```js
import assert from 'assert'
import { isValidChecksumAddress, unpadBuffer, BN } from 'ethereumjs-util'

assert.ok(isValidChecksumAddress('0x2F015C60E0be116B1f0CD534704Db9c92118FB6A'))

assert.ok(unpadBuffer(Buffer.from('000000006600', 'hex')).equals(Buffer.from('6600', 'hex')))

assert.ok(new BN('dead', 16).add(new BN('101010', 2)).eqn(57047))
```

# API

## Documentation

Read the [API docs](docs/).

### Modules

- [account](src/account.ts)
  - Account class
  - Private/public key and address-related functionality (creation, validation, conversion)
- [address](src/address.ts)
  - Address class and type
- [bytes](src/bytes.ts)
  - Byte-related helper and conversion functions
- [constants](src/constants.ts)
  - Exposed constants
    - e.g. `KECCAK256_NULL_S` for string representation of Keccak-256 hash of null
- [hash](src/hash.ts)
  - Hash functions
- [object](src/object.ts)
  - Helper function for creating a binary object (`DEPRECATED`)
- [signature](src/signature.ts)
  - Signing, signature validation, conversion, recovery
- [types](src/types.ts)
  - Helpful TypeScript types
- [internal](src/internal.ts)
  - Internalized helper methods
- [externals](src/externals.ts)
  - Re-exports of `BN`, `rlp`

### ethjs-util methods

The following methods are available by an internalized version of the [ethjs-util](https://github.com/ethjs/ethjs-util) package (`MIT` license), see [internal.ts](src/internal.ts). The original package is not maintained any more and the original functionality will be replaced by own implementations over time (starting with the `v7.1.3` release, October 2021).

- arrayContainsArray
- getBinarySize
- stripHexPrefix
- isHexPrefixed
- isHexString
- padToEven
- fromAscii
- fromUtf8
- toUtf8
- toAscii
- getKeys

They can be imported by name:

```js
import { stripHexPrefix } from 'ethereumjs-util'
```

### Re-Exports

`ethereumjs-util` re-exports the following commonly-used libraries:

- [BN.js](https://github.com/indutny/bn.js) (version `5.x`)
- [rlp](https://github.com/ethereumjs/rlp) (version `2.x`)

They can be imported by name:

```js
import { BN, rlp } from 'ethereumjs-util'
```

# EthereumJS

See our organizational [documentation](https://ethereumjs.readthedocs.io) for an introduction to `EthereumJS` as well as information on current standards and best practices.

If you want to join for work or do improvements on the libraries have a look at our [contribution guidelines](https://ethereumjs.readthedocs.io/en/latest/contributing.html).

# LICENSE

MPL-2.0

[util-npm-badge]: https://img.shields.io/npm/v/ethereumjs-util.svg
[util-npm-link]: https://www.npmjs.org/package/ethereumjs-util
[util-issues-badge]: https://img.shields.io/github/issues/ethereumjs/ethereumjs-monorepo/package:%20util?label=issues
[util-issues-link]: https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aopen+is%3Aissue+label%3A"package%3A+util"
[util-actions-badge]: https://github.com/ethereumjs/ethereumjs-monorepo/workflows/Util/badge.svg
[util-actions-link]: https://github.com/ethereumjs/ethereumjs-monorepo/actions?query=workflow%3A%22Util%22
[util-coverage-badge]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/branch/master/graph/badge.svg?flag=util
[util-coverage-link]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/tree/master/packages/util
[discord-badge]: https://img.shields.io/static/v1?logo=discord&label=discord&message=Join&color=blue
[discord-link]: https://discord.gg/TNwARpR

---
_Source: https://npm.io/package/ethereumjs-util · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
