# tbc-lib-js

> A library for tbc functionality

Latest version **1.0.31** (published 2026-07-30) · OpenTBC license · 0 weekly downloads

## Install

```sh
npm install tbc-lib-js
pnpm add tbc-lib-js
yarn add tbc-lib-js
bun add tbc-lib-js
```

## Health

**Score 55/100 (C)** — status: active.

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.31 |
| Published | 2026-07-30 |
| First published | 2024-07-04 |
| Weekly downloads | 0 |
| License | OpenTBC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 12 |
| Unpacked size | 724.4 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Austin |
| Maintainers | austinwong |
| Keywords | tbc, bitcoin, transaction, address, p2p, ecies, cryptocurrency, blockchain, payment, bip21, bip32, bip37, bip69, bip70 |

## Links

- npm: https://www.npmjs.com/package/tbc-lib-js
- Repository: https://github.com/TuringBitChain/tbc-lib-js
- Homepage: https://github.com/TuringBitChain/tbc-lib-js#readme
- Issues: https://github.com/TuringBitChain/tbc-lib-js/issues
- npm.io page: https://npm.io/package/tbc-lib-js

## Dependencies (12)

- [bs58](https://npm.io/package/bs58.md) =4.0.1
- [axios](https://npm.io/package/axios.md) ^1.7.7
- [bn.js](https://npm.io/package/bn.js.md) 4.12.3
- [unorm](https://npm.io/package/unorm.md) 1.4.1
- [aes-js](https://npm.io/package/aes-js.md) ^3.1.2
- [bech32](https://npm.io/package/bech32.md) ^2.0.0
- [hash.js](https://npm.io/package/hash.js.md) ^1.1.7
- [elliptic](https://npm.io/package/elliptic.md) 6.6.1
- [inherits](https://npm.io/package/inherits.md) 2.0.3
- [secp256k1](https://npm.io/package/secp256k1.md) ^5.0.1
- [clone-deep](https://npm.io/package/clone-deep.md) ^4.0.1
- [bignumber.js](https://npm.io/package/bignumber.js.md) ^9.1.2

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.0.31 (latest) — 2026-07-30
- 1.0.30 — 2026-04-22
- 1.0.29 — 2025-12-23
- 1.0.28 — 2025-08-28
- 1.0.27 — 2025-04-24
- 1.0.26 — 2025-04-24
- 1.0.25 — 2025-01-24
- 1.0.24 — 2025-01-17
- 1.0.23 — 2025-01-17
- 1.0.22 — 2025-01-17
- 1.0.21 — 2025-01-07
- 1.0.20 — 2024-12-30
- 1.0.19 — 2024-12-27
- 1.0.18 — 2024-12-24
- 1.0.17 — 2024-12-20
- … 17 more at https://npm.io/package/tbc-lib-js/versions

## README

tbc
===

Javascript Turing BC library.

To get started, just `npm install tbc-lib-js`.

Please see ./doc for documents details.


A transaction construct demo program:
```ts
const Transaction = require('tbc-lib-js/lib/transaction/transaction');
const PrivateKey = require('tbc-lib-js/lib/privatekey');
const Address = require('tbc-lib-js/lib/address');
const Script = require('tbc-lib-js/lib/script');
const Signature = require('tbc-lib-js/lib/crypto/signature');  // Import the Signature module
const Mnemonic = require('tbc-lib-js/lib/mnemonic/mnemonic');
const PublicKey = require('tbc-lib-js/lib/publickey');

// generate mnemonic
//const mnemonic = new Mnemonic();
const mnemonic = Mnemonic.fromString(
    "word word word word word word word word word word word word",
    Mnemonic.Words.ENGLISH
);

// get HDPrivateKey from mnemonic
const HDPrivateKey = mnemonic.toHDPrivateKey('','livenet');

// create private key from seed with compressed format
// will sign the transaction with this private key
const DerivationPath = "m/44'/236'/0'/1/0";
const derivedHDPrivateKey =HDPrivateKey.deriveChild(DerivationPath);
const privateKey = derivedHDPrivateKey.privateKey;

// get public key from private key
const publicKey = privateKey.toPublicKey();

// get WIF private key
const wif = privateKey.toWIF();

// get address from private key
const address = privateKey.toAddress();

// print results
console.log('private key:', privateKey.toString());
console.log('public key:', publicKey.toString());
console.log('WIF private key (compressed):', wif);
console.log('mnemonic:', mnemonic.phrase);
console.log('address:', address.toString());



// Create a new transaction
const transaction = new Transaction();

// Add the first input
const utxo1 = {
    txId: '<txid>',
    outputIndex: 0,
    script: '<lockingScript>',
    satoshis: 50000000
};
transaction.from(utxo1);

//Add the second input
// const utxo2 = {
//     txId: '<txid>',
//     outputIndex: 1,
//     script: '<lockingScript>',
//     satoshis: 50000000
// };
// transaction.from(utxo2);

// Set the output
const toAddress = new Address('1Jb...');
const amount = 40000000;
transaction.to(toAddress, amount);

// Set the change address
const changeAddress = new Address('1B2...');
transaction.change(changeAddress);

// Set the fee
const fee = 1000;
transaction.fee(fee);

// Explicitly sign each input
transaction.sign(privatekey, Signature.SIGHASH_ALL | Signature.SIGHASH_FORKID);
//transaction.sign(privateKey2, Signature.SIGHASH_ALL | Signature.SIGHASH_FORKID);


// Serialize the transaction
const serializedTransaction = transaction.serialize();
console.log('Serialized Transaction:', serializedTransaction);
```

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