ethereumjs-util

by ethereumjs

ethereumjs /ethereumjs-util

A collection of utility functions for Ethereum

484 Stars 243 Forks Last release: about 2 months ago (v7.0.4) Mozilla Public License 2.0 590 Commits 40 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

SYNOPSIS

NPM Package Actions Status Coverage Status Gitter

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
    • 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. KECCAK256NULLS 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
  • externals
    • Helper methods from
      ethjs-util
    • Re-exports of
      BN
      ,
      rlp

ethjs-util methods

The following methods are available provided by ethjs-util:

  • arrayContainsArray
  • toBuffer
  • getBinarySize
  • stripHexPrefix
  • isHexPrefixed
  • isHexString
  • padToEven
  • intToHex
  • fromAscii
  • fromUtf8
  • toUtf8
  • toAscii
  • getKeys

Import can be done directly by function name analogous to the build-in function import:

import { intToHex, stripHexPrefix } from 'ethereumjs-util'

Re-Exports

Additionally

ethereumjs-util
re-exports a few commonly-used libraries. These include:

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

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.