# @arcblock/forge-util

> utils shared across mutlipe forge js libs, works in both node.js and browser

Latest version **1.8.0** (published 2025-08-05) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @arcblock/forge-util
pnpm add @arcblock/forge-util
yarn add @arcblock/forge-util
bun add @arcblock/forge-util
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.8.0 |
| Published | 2025-08-05 |
| First published | 2019-02-22 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 24.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 26 |
| Author | wangshijun |
| Maintainers | wangshijun, polunzh, mave99a, gxw |
| Keywords | forge, arcblock, node.js, browser, sdk |

## Links

- npm: https://www.npmjs.com/package/@arcblock/forge-util
- Repository: https://github.com/ArcBlock/forge-js
- Homepage: https://github.com/ArcBlock/forge-js/tree/master/forge/forge-util
- Issues: https://github.com/ArcBlock/forge-js/issues
- npm.io page: https://npm.io/package/@arcblock/forge-util

## Dependencies (5)

- [utf8](https://npm.io/package/utf8.md) ^3.0.0
- [bn.js](https://npm.io/package/bn.js.md) 5.1.3
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [multibase](https://npm.io/package/multibase.md) ^3.1.2
- [base64-url](https://npm.io/package/base64-url.md) ^2.3.3

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.8.0 (latest) — 2025-08-05
- 1.7.1 — 2022-09-07
- 1.7.0 — 2022-09-07
- 1.6.3 — 2021-04-21
- 1.6.2 — 2021-03-17
- 1.6.1 — 2021-03-12
- 1.6.0 — 2021-03-04
- 1.5.8 — 2021-01-19
- 1.5.7 — 2021-01-18
- 1.5.6 — 2021-01-14
- 1.5.5 — 2020-12-31
- 1.5.4 — 2020-12-31
- 1.5.3 — 2020-12-29
- 1.5.2 — 2020-12-27
- 1.5.1 — 2020-12-23
- … 88 more at https://npm.io/package/@arcblock/forge-util/versions

## README

![forge-util](https://www.arcblock.io/.netlify/functions/badge/?text=forge-util)

[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![docs](https://img.shields.io/badge/powered%20by-arcblock-green.svg)](https://docs.arcblock.io)
[![Gitter](https://badges.gitter.im/ArcBlock/community.svg)](https://gitter.im/ArcBlock/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

> Utility functions to ease crypto/encoding related tasks, some methods are migrated from [web3-utils](https://github.com/ethereum/web3.js/blob/1.0/packages/web3-utils/README.md)


## Usage

```shell
yarn add @arcblock/forge-util
# OR
npm i @arcblock/forge-util -S
```

```javascript
const Util = require('@arcblock/forge-util');

console.log(Util.fromTokenToUnit(100)); // 100_0000_0000_0000_0000
console.log(Util.fromUnitToToken('1000000000000000000')); // 100
console.log(Util.isStrictHex('0x123abc')); // true
```


## API List

Following are the most used methods in `@arcblock/forge-util`:

* `toHex`: convert any value to hex encoded string
* `fromUnitToToken`: convert human readable token presentation to big number
* `fromTokenToUnit`: convert big number to human readable token representation
* `toUint8Array`: convert any value to Uint8Array
* `toBuffer`: convert any value to buffer
* `toBase58`: convert any value to base58 format
* `fromBase58`: convert base58 format to buffer
* `toBase64`: convert any value to base64 url encoded string
* `fromBase64`: convert base64 url encoded string to buffer
* `UUID`: generate a random UUID
* `isUUID`: check if a string is valid UUID
* `toDid`: prepend an did with `did:abt:` prefix
* `toAddress`: remove `did:abt:` prefix

Checkout [lib/index.d.ts](./lib/index.d.ts) for more API.
Checkout [tests/index.spec.js](./tests/index.spec.js) for more usage examples.


## Documentation

For full documentation, checkout [https://forge-js.netlify.com](https://forge-js.netlify.com/)

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