ethereumjs-util
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@types/bn.js | 5.1.5 | 3.59 kB | MIT | prod | |
bn.js | 5.2.1 | 21.32 kB | MIT | prod | |
create-hash | 1.2.0 | 2.39 kB | MIT | prod | |
ethereum-cryptography | 0.1.3 | 175.35 kB | MIT | prod | 2 |
rlp | 2.2.7 | 13.59 kB | MPL-2.0 | prod | 1 |
Ethereumjs-util is a collection of utility functions specifically designed for Ethereum. With capabilities that can function both in Node.js and in the browser (thanks to browserify), this package offers a spectrum of functionalities related to Ethereum. Key features include account creation, validation, conversion, byte-related helper and conversion methods, hash functions, signature validation, and more. The tool is also able to re-export commonly used libraries such as BN.js and rlp for greater convenience.
In order to use ethereumjs-util, you first need to install it using npm with the command npm install ethereumjs-util
. Once installed, you can import and use any function from ethereumjs-util. Here is a simple code usage example:
import assert from 'assert'
import { isValidChecksumAddress, unpadBuffer, BN } from 'ethereumjs-util'
// Validating Ethereum address
assert.ok(isValidChecksumAddress('0x2F015C60E0be116B1f0CD534704Db9c92118FB6A'))
// Unpadding a buffer
assert.ok(unpadBuffer(Buffer.from('000000006600', 'hex')).equals(Buffer.from('6600', 'hex')))
// Using BN.js for arithmetic operation
assert.ok(new BN('dead', 16).add(new BN('101010', 2)).eqn(57047))
Another feature of ethereumjs-util is the re-exportation of popularly used libraries. Here's a sample usage:
// Importing BN.js and rlp from ethereumjs-util
import { BN, rlp } from 'ethereumjs-util'
The package also provides an internalized version of the ethjs-util package with available methods that can be directly imported:
// Importing a method from ethjs-util
import { stripHexPrefix } from 'ethereumjs-util'
The documentation for ethereumjs-util can be found in the API docs section. For more detailed package overview and standards, the EthereumJS organizational documentation is a useful reference.