ethereumjs-util
    TypeScript icon, indicating that this package has built-in type declarations

    7.1.3 • Public • Published

    SYNOPSIS

    NPM Package GitHub Issues Actions Status Code Coverage Discord

    A collection of utility functions for Ethereum. It can be used in Node.js and in the browser with browserify.

    INSTALL

    npm install ethereumjs-util

    USAGE

    import assert from 'assert'
    import { isValidChecksumAddress, unpadBuffer, BN } from 'ethereumjs-util'
    
    const address = '0x2F015C60E0be116B1f0CD534704Db9c92118FB6A'
    assert.ok(isValidChecksumAddress(address))
    
    assert.equal(unpadBuffer(Buffer.from('000000006600', 'hex')), Buffer.from('6600', 'hex'))
    
    assert.equal(new BN('dead', 16).add(new BN('101010', 2)), 57047)

    API

    Documentation

    Modules

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

    Also see API docs.

    ethjs-util methods

    The following methods are available by an internalized version of the ethjs-util package (MIT license), see 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:

    import { stripHexPrefix } from 'ethereumjs-util'

    Re-Exports

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

    EthereumJS

    See our organizational documentation 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.

    LICENSE

    MPL-2.0

    Install

    npm i ethereumjs-util

    DownloadsWeekly Downloads

    1,357,508

    Version

    7.1.3

    License

    MPL-2.0

    Unpacked Size

    300 kB

    Total Files

    87

    Last publish

    Collaborators

    • holgerd77
    • evertonfraga
    • ralxz
    • null_radix
    • axic
    • jwasinger