Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Examples in README #236

Merged
merged 2 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 58 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,70 @@
[![Coverage Status](https://img.shields.io/coveralls/ethereumjs/ethereumjs-util.svg?style=flat-square)](https://coveralls.io/r/ethereumjs/ethereumjs-util)
[![Gitter](https://img.shields.io/gitter/room/ethereum/ethereumjs-lib.svg?style=flat-square)](https://gitter.im/ethereum/ethereumjs-lib) or #ethereumjs on freenode

A collection of utility functions for ethereum. It can be used in node.js or can be in the browser with browserify.
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, unpad, BN } from 'ethereumjs-util'

const address = '0x2F015C60E0be116B1f0CD534704Db9c92118FB6A'
assert.ok(isValidChecksumAddress(address))

assert.equal(unpad('0000000006600'), '6600')

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

# API

[./docs/](./docs/README.md)
## Documentation

### Modules

- [account](docs/modules/_account_.md)
- Private/public key and address-related functionality (creation, validation, conversion)
- [bytes](docs/modules/_bytes_.md)
- Byte-related helper and conversion functions
- [constants](docs/modules/_constants_.md)
- Exposed constants
- e.g. KECCAK256_NULL_S for string representation of Keccak-256 hash of null
- [hash](docs/modules/_hash_.md)
- Hash functions
- [object](docs/modules/_object_.md)
- Helper function for creating a binary object (`DEPRECATED`)
- [signature](docs/modules/_signature_.md)
- Signing, signature validation, conversion, recovery
- [externals](docs/modules/_externals_.md)
- Helper methods from `ethjs-util`
- Re-exports of `BN`, `rlp`, `secp256k1`

### ethjs-util methods

The following methods are available provided by [ethjs-util](https://github.com/ethjs/ethjs-util):

Most of the string manipulation methods are provided by [ethjs-util](https://github.com/ethjs/ethjs-util)
- arrayContainsArray
- toBuffer
- getBinarySize
- stripHexPrefix
- isHexPrefixed
- isHexString
- padToEven
- intToHex
- fromAscii
- fromUtf8
- toUtf8
- toAscii
- getKeys

---
### Re-Exports

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

- `BN` ([bn.js](https://github.com/indutny/bn.js))
- `rlp` ([rlp](https://github.com/ethereumjs/rlp))
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/_externals_.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Module: "externals"

Re-exports commonly used modules:
* Adds [`ethjsUtil`](https://github.com/ethjs/ethjs-util) methods.
* Exports [`BN`](https://github.com/indutny/bn.js), [`rlp`](https://github.com/ethereumjs/rlp), [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/)`.
* Adds [`ethjs-util`](https://github.com/ethjs/ethjs-util) methods.
* Exports [`BN`](https://github.com/indutny/bn.js), [`rlp`](https://github.com/ethereumjs/rlp), [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/).
4 changes: 2 additions & 2 deletions src/externals.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Re-exports commonly used modules:
* * Adds [`ethjsUtil`](https://github.com/ethjs/ethjs-util) methods.
* * Exports [`BN`](https://github.com/indutny/bn.js), [`rlp`](https://github.com/ethereumjs/rlp), [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/)`.
* * Adds [`ethjs-util`](https://github.com/ethjs/ethjs-util) methods.
* * Exports [`BN`](https://github.com/indutny/bn.js), [`rlp`](https://github.com/ethereumjs/rlp), [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/).
* @packageDocumentation
*/

Expand Down