# wif

> Bitcoin Wallet Import Format (WIF) decoding/encoding module

Latest version **5.0.0** (published 2024-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install wif
pnpm add wif
yarn add wif
bun add wif
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2024-06-25 |
| First published | 2015-08-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 87 |
| Author | Daniel Cousens |
| Keywords | bitcoin, base58, base58check, decode, decoding, encoding, encode, key, private, wif |

## Links

- npm: https://www.npmjs.com/package/wif
- Repository: https://github.com/bitcoinjs/wif
- Issues: https://github.com/bitcoinjs/wif/issues
- npm.io page: https://npm.io/package/wif

## Dependencies (1)

- [bs58check](https://npm.io/package/bs58check.md) ^4.0.0

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2024-06-25
- 4.0.0 — 2023-08-29
- 2.0.6 — 2017-04-20
- 3.0.1 — 2017-04-19
- 3.0.0 — 2017-04-19
- 2.0.5 — 2017-04-19
- 2.0.4 — 2016-12-01
- 2.0.3 — 2016-10-27
- 2.0.2 — 2016-10-27
- 2.0.1 — 2016-02-02
- 2.0.0 — 2016-01-12
- 1.2.1 — 2015-10-20
- 1.2.0 — 2015-08-26
- 1.1.2 — 2015-08-20
- 1.1.1 — 2015-08-20
- … 3 more at https://npm.io/package/wif/versions

## README

# WIF
[![TRAVIS](https://secure.travis-ci.org/bitcoinjs/wif.png)](http://travis-ci.org/bitcoinjs/wif)
[![NPM](http://img.shields.io/npm/v/wif.svg)](https://www.npmjs.org/package/wif)

[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

Bitcoin Wallet Import Format encoding/decoding module.


## Example

``` javascript
import * as wif from "wif"
var privateKey = Buffer.from('0000000000000000000000000000000000000000000000000000000000000001', 'hex')
var key = wif.encode({version: 128, privateKey, compressed: true}) // for the testnet use: wif.encode(239, ...
// => KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn

var obj = wif.decode(key)
// => {
//	version: 128,
//	privateKey: Uint8Array(32) [
//     0, 0, 0, 0, 0, 0, 0, 0, 0,
//     0, 0, 0, 0, 0, 0, 0, 0, 0,
//     0, 0, 0, 0, 0, 0, 0, 0, 0,
//     0, 0, 0, 0, 1
//   ],
//	compressed: true
//}

wif.decode(key, 0x09)
// => Error: Invalid network version

// alternative syntax
wif.encode(obj)
// => KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn
```

## LICENSE [MIT](LICENSE)

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