open-index/open-npm huggingface dataset:
npm package: @jadepool/lib-bitcoin
Description: Bitcoin Transaction Builder for NodeJS - Jadepool
Author: Tang Bo Hao
Latest version: 0.1.0-alpha.1

# Bitcoin Transaction Builder for NodeJS

[![License](https://img.shields.io/npm/l/@jadepool/lib-bitcoin.svg)](LICENSE)

One of Jadepool support library - Bitcoin transaction builder.

## How to install

```bash
npm install @jadepool/lib-bitcoin
```

## How to use

```js
  const lib = require('@jadepool/lib-bitcoin')
  const pubKey = 'ECDSA PUBLIC KEY'
  // genAddressByPubKey
  const address = lib.genAddressByPubKey(pubKey, true) // true for testnet
  // validateAddress
  const isValid = lib.validateAddress(address, true)
  // composeUnsignedTransferTx
  const transferInfo = {
    inputs: [
      { // utxo info
        address: 'fromAddress',
        scriptPubKey: 'from utxo info.',
        txid: 'from utxo info.',
        vout: 0 // from utxo info
      }
    ],
    outputs: [
      {
        address: 'toAddress',
        satoshi: 'shatoshi no decimal'
      }
    ],
    // optional for Omni(like USDT)
    omni: {
      from: 'fromAddress',
      to: 'toAddress',
      value: 'amount no decimal',
      // optional
      contract: 'omni contract', // optional, default is 6f6d6e69
      propertyId: 31, // optional, default is 31(USDT in mainnet)
    }
  }
  // return unsignedInputs
  const { inputs/* [{ vin, address, unsignedHash }] */, rawtx } = lib.composeUnsignedTransferTx(transferInfo, true)
  // buildTransferTx
  const sigs = [
    {
      vin: 0,
      signature: 'sig hex',
      pubKey: 'public key'
    }
  ]
  const { txid, rawtx } = lib.buildTransferTx(transferInfo, sigs, true)
```
npm package: @jadepool/lib-core
Description: Jadepool core library
Author: tech@btang.cn
Latest version: 0.22.28

# Jadepool NodeJS lib-core

[![License](https://img.shields.io/npm/l/@jadepool/lib-core.svg)](LICENSE)

瑶池支持库，含基础主要services等

## 初始化

```js
const { jadepool } = require('@jadepool/lib-core')
// 版本号
const version = '0.1.0'
// 一般性method call，传入后可使用jadepool.invokeMethod(methodName, namespace, args)
const invokeMethodWrapper = useJadepoolInvoke ? require('path/to/method') : undefined
// 配置对象，全局配置缓存
const config = require('config')
// 可自行extends jadepool.Context 上下文类
const ctx = new jadepool.Context(consts.SERVER_TYPES.UNKNOWN, version, invokeMethodWrapper, config)
// 瑶池支持库初始化
await jadepool.initialize(ctx)
```

## 获取模型

```js
const { jadepool } = require('@jadepool/lib-core')
const Model = jadepool.getModel('modelName')
// 后续可用 Model.findOne(...)
```

## 获取服务

```js
const { jadepool } = require('@jadepool/lib-core')
// 可获取 consts.SERVICE_NAMES 内的全部服务
const someSrv = jadepool.getService(consts.SERVICE_NAMES.JSONRPC)
```

## 一般性调用

```js
const { jadepool } = require('@jadepool/lib-core')
// 使用一般性调用必须在初始化时传入invokeMethodWrapper
// 定义为 function (methodName: string, namespace: string, args: any): Promise<any>
const result = await jadepool.invokeMethod('some-method-name')
```

## 获取MongoDB实例

```js
const { utils } = require('@jadepool/lib-core')
const connKey = 'default'
const conn = utils.db.fetchConnection(connKey)
```
npm package: @jadepool/lib-cosmos
Description: Corelib for cosmos
Author: Tang Bo Hao
Latest version: 0.4.0

# Cosmos NodeJS lib

## How to use

```js
  const libcosmos = require('@jadepool/lib-cosmos')
  // genAddress
  const addr = libcosmos.genAddressByPubKey(pubKey)
  // getUnsignedTx
  const txString = `${addr}=1stake;${addr}=2stake`
  const unsignedTx = libcosmos.composeUnsignedTx(addr, txString, 'test-chain', 0, 1, 100000, '0.0001stake', 1.0, '')
  // getRawTx
  const sig = 'signiture'
  const pubKey = 'publickKey'
  const isReturnJson = true
  const rawtx = libcosmos.buildRawTx(addr, txString, 'test-chain', 0, 1, 100000, '0.0001stake', 1.0, '', sig, pubKey, isReturnJson)
```
npm package: @jadepool/lib-ethereum
Description: Ethereum Transaction Builder for NodeJS - Jadepool
Author: Tang Bo Hao
Latest version: 0.2.0

# Ethereum Transaction Builder for NodeJS

[![License](https://img.shields.io/npm/l/@jadepool/lib-ethereum.svg)](LICENSE)

One of Jadepool support library - Ethereum transaction builder.

## How to install

```bash
npm install @jadepool/lib-ethereum
```

## How to use

```js
  const lib = require('@jadepool/lib-ethereum')
  const pubKey = 'ECDSA PUBLIC KEY'
  // genAddressByPubKey
  const address = lib.genAddressByPubKey(pubKey)
  // normalizeAddress
  const normalizedAddress = lib.normalizeAddress(address.toLowerCase())
  // validateAddress
  const isValid = lib.validateAddress(address)
  // composeUnsignedTransferTx
  const transferInfo = {
    from: 'fromAddress',
    to: 'toAddress',
    value: 'amount',
    // optional for ERC20 or ERC721, format: '0x123...321' or 'ERC20:0x123...321' or 'ERC721:0x123...321'
    contract: 'contract address', // optional
    usingTransferFrom: false, // optional, using transferFrom method or not
  }
  const params = {
    nonce: 0,
    chainId: 42,
    gasPrice: 1e9, // this is default
    gasLimit: 21000 // this is default
  }
  const { unsignedHash, rawtx } = lib.composeUnsignedTransferTx(info, params)
  // buildTransferTx
  const signature = 'sig hex'
  const recovery = 1
  const { txid, rawtx } = lib.buildTransferTx(info, params, signature, recovery)
  // or build by public key
  const { txid, rawtx } = lib.buildTransferTx(info, params, signature, pubKey)
```
npm package: @jadepool/lib-qlink
Description: NodeJS lib for QLink
Author: Tang Bo Hao
Latest version: 0.1.2

# QLink NodeJS lib

## How to use

```js
  const libqlink = require('@jadepool/lib-qlink')
  // genAddress
  const addr = libqlink.genAddressByPriKey(privKey)
  // fillBlock, require the block json from QLink's jsonrpc
  const stateBlock = `{
    "type": "state",
    "token":"991cf190094c00f0b68e2e5f75f6bee95a2e0bd93ceaa4a6734db9f19b728949",
    "address":"qlc_3pjn4swtnsr8ujkyyorci5bjyhuegdkisx9te7tr7yztf4mtr1xqzz8fofih",
    "balance": "1456778",
    "previous": "247230c7377a661e57d51b17b527198ed52392fb8b99367a234d28ccc378eb05",
    "link": "7d35650e78d8d7037c90390357f8a59bf17eff82cbc03c94f0b6267335a8dcb3",
    "sender": "IjE1ODExMTEwMDAwMCI=",
    "receiver": "IjE1ODExMTEwMDAwMCI=",
    "message": "1235650e78d8d7037c90390357f8a59bf17eff82cbc03c94f0b6267335a8dcb3",
    "data": "DCI4Tg==",
    "quota": 12345612,
    "timestamp": 783474523,
    "extra": "1235650e78d297037c90390357f8a59bf17eff82cbc03c94f0b6267335a8dcb3",
    "representative": "qlc_1c47tsj9cipsda74no7iugu44zjrae4doc8yu3m6qwkrtywnf9z1qa3badby"
  }
  `
  const blockWithWorkAndSig = lib.fillBlock(testBlk, privKey)
  // blockWithWorkAndSig is the json with 'work' and 'signature'
```