# cexdb

> Allows you to create hd wallets and store data on connected db

Latest version **0.0.4** (published 2022-05-16) · ISC license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2022-05-16 |
| First published | 2022-05-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 21 |
| Unpacked size | 162.7 KB |
| Known vulnerabilities | 0 (+26 in 2 direct dependencies) |
| Install scripts | no |
| Author | Onah Prosperity |
| Maintainers | godsprosperity |

## Links

- npm: https://www.npmjs.com/package/cexdb
- npm.io page: https://npm.io/package/cexdb

## Dependencies (21)

- [web3](https://npm.io/package/web3.md) ^1.5.3
- [axios](https://npm.io/package/axios.md) ^0.21.4
- [bip32](https://npm.io/package/bip32.md) ^2.0.6
- [bip39](https://npm.io/package/bip39.md) ^3.0.4
- [hdkey](https://npm.io/package/hdkey.md) ^2.0.1
- [mssql](https://npm.io/package/mssql.md) ^7.2.1
- [express](https://npm.io/package/express.md) ^4.17.1
- [mongodb](https://npm.io/package/mongodb.md) ^4.1.4
- [mongoose](https://npm.io/package/mongoose.md) ^5.10.14
- [bs58check](https://npm.io/package/bs58check.md) ^2.1.2
- [bitcore-lib](https://npm.io/package/bitcore-lib.md) ^8.25.10
- [create-hash](https://npm.io/package/create-hash.md) ^1.2.0
- [bitcoinjs-lib](https://npm.io/package/bitcoinjs-lib.md) ^5.2.0
- [dotenv-defaults](https://npm.io/package/dotenv-defaults.md) ^3.0.0
- [ethereumjs-util](https://npm.io/package/ethereumjs-util.md) ^7.1.1
- [bitcoin-computer](https://npm.io/package/bitcoin-computer.md) ^0.4.7-beta
- [bitcore-explorers](https://npm.io/package/bitcore-explorers.md) ^1.0.1
- [ethereumjs-wallet](https://npm.io/package/ethereumjs-wallet.md) ^1.0.2
- [mssql-tedious-1-11-4](https://npm.io/package/mssql-tedious-1-11-4.md) ^2.2.1
- [wallet-address-validator](https://npm.io/package/wallet-address-validator.md) ^0.2.4
- [truffle-hdwallet-provider](https://npm.io/package/truffle-hdwallet-provider.md) ^1.0.17

## Recent versions

- 0.0.4 (latest) — 2022-05-16
- 0.0.3 — 2022-05-14
- 0.0.2 — 2022-05-14
- 0.0.1 — 2022-05-14

## README

<h1 align="center"> cex HD Wallet Api </h1>
<p align="center">Node.js module for creating hd wallets and performing other blockchain operations</p>
<P ALIGN="ceter"> useful link https://en.bitcoin.it/wiki/List_of_address_prefixes </p>


<h2>Install</h2>

```sh
npm i cexdb
```
<h2>Usage</h2>

```js
const cex = require("cex")

// Takes in a wallet name that will be stored on the db and create BTC mnemonics
// return false if walletname already exist
cex.createBTCHdWallet(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Takes in a wallet name that will be stored on the db and create ETH mnemonics
// return false if walletname already exist
cex.createETHHdWallet(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)


// Takes in a wallet name that will be stored on the db and create BSC mnemonics
// return false if walletname already exist
cex.createBSCHdWallet(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Takes in a wallet name that was stored on the db and generate BTC wallet address.
// return false if walletname doesnt exist
// returns BTC wallet address, it private key
cex.generateBTCAddress(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Takes in a wallet name that was stored on the db and generate ETH wallet address.
// return false if walletname doesnt exist
// returns BTC wallet address, it private key
cex.generateETHAddresses(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Takes in a wallet name that was stored on the db and generate BSC wallet address.
// return false if walletname doesnt exist
// returns BTC wallet address, it private key

cex.generateBSCAddresses(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Get metadata for a particular address
//all data relevant for using this address..
cex.getAddressMeta(pipeline, address).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// get all wallet ON btc
cex.getAllBTCWallets().then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// get all wallet ON eth
cex.getAllETHWallets().then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// get all wallet ON BSC
cex.getAllBSCWallets().then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// transfer currencies
// pipeline : if "ETH" then it will transfer ETHER in Ethereum network
//          if "BSC" then it will transfer BNB in Binance smartchain network
//          if "BTC" then it will transfer BTC in Bitcoin Network
// sender address
// receiever address
// amount
// IF SENDER ADDRESS DOESNT EXIST, RETURN FALSE.
// // TransferBtc("ETH", "0x4BF815Ef22628bFe3988B16fC5819B0262C3d3A6", "0xC655114468c3a7bdCF7457c91cb5ab541e528Bf8", 15);
cex.Transfer(pipeline, senderAddress, recieverAddress, amount).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// transfer USDT in both Ethereum and Binance network 
// pipeline : if "ETH" then it will transfer USDT in Ethereum network
//          if "BSC" then it will transfer USDT in Binance smartchain network
// sender address
// receiever address
// amount
// IF SENDER ADDRESS DOESNT EXIST, RETURN FALSE.
// // TransferBtc("ETH", "0x4BF815Ef22628bFe3988B16fC5819B0262C3d3A6", "0xC655114468c3a7bdCF7457c91cb5ab541e528Bf8", 15); 
cex.TransferUSDT(pipeline, senderAddress, recieverAddress, amount).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// transfer BTC in both Ethereum and Binance network 
// pipeline : if "ETH" then it will transfer USDT in Ethereum network
//          if "BSC" then it will transfer USDT in Binance smartchain network
// sender address
// receiever address
// amount
// IF SENDER ADDRESS DOESNT EXIST, RETURN FALSE.
// // TransferBtc("ETH", "0x4BF815Ef22628bFe3988B16fC5819B0262C3d3A6", "0xC655114468c3a7bdCF7457c91cb5ab541e528Bf8", 15); 
cex.TransferBTC(pipeline, senderAddress, recieverAddress, amount).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// transfer ETH in Binance network 
// sender address
// receiever address
// amount
// IF SENDER ADDRESS DOESNT EXIST, RETURN FALSE.
// // TransferBtc("ETH", "0x4BF815Ef22628bFe3988B16fC5819B0262C3d3A6", "0xC655114468c3a7bdCF7457c91cb5ab541e528Bf8", 15); 
cex.TransferETHOnBSC(senderAddress, recieverAddress, amount).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// transfer BNB in ETHEREUM network 
// sender address
// receiever address
// amount
// IF SENDER ADDRESS DOESNT EXIST, RETURN FALSE.
// // TransferBtc("ETH", "0x4BF815Ef22628bFe3988B16fC5819B0262C3d3A6", "0xC655114468c3a7bdCF7457c91cb5ab541e528Bf8", 15); 
cex.TransferBNBOnETH(senderAddress, recieverAddress, amount).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

//Get the Balance on a particular address
// Verify/Specify that input address is BTC address
cex.getBTCAddressBalance(address).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

//Get the Balance on a particular address
// Verify/Specify that input address is ETH address
cex.getETHAddressBalance(address).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

//Get the Balance on a particular address
// Verify/Specify that input address is BSC address
cex.getBSCAddressBalance(address).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)


// Delete address from a wallet
cex.deleteAddressFromBTCWallet(address).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Delete address from a wallet
cex.deleteAddressFromBSCWallet(address).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Delete address from a wallet
cex.deleteAddressFromETHWallet(address).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Delete Wallet_Name completely from the server
// name of wallet to destroy
cex.destroyBTCHdWallet(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Delete Wallet_Name completely from the server
// name of wallet to destroy
cex.destroyETHHdWallet(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Delete Wallet_Name completely from the server
// name of wallet to destroy
cex.destroyBSCHdWallet(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)
//

// return associated details with the wallet name
cex.getBTCWalletMeta(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// return associated details with the wallet name
cex.getETHWalletMeta(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// return associated details with the wallet name
cex.getBSCWalletMeta(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Convert Btc to others equivalent
// other is the name of the asset to convert into
// 
// other should include: 
// - ETH || ether
// - BNB
// - USD
cex.getBTCToOthersRate(other).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// - check if wallet exist on the db
// - if wallet exist it return true otherwise false
cex.checkBTCWalletExists(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// - check if wallet exist on the db
// - if wallet exist it return true otherwise false
cex.checkBSCWalletExists(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// - check if wallet exist on the db
// - if wallet exist it return true otherwise false
cex.checkETHWalletExists(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// - check if Address exist on the pipeline
// - if address exist it return true otherwise return false
cex.checkIfAddressExists(pipeline, address).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// - get the total balance of all the addresses associated with the wallet_name
// wallet_name must exist on the server.
cex.getWalletAddressesBalance(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

//Get Transaction Information/Confirmation...
// getBTCTransaction("3KHvxwMriN9bh3Hk1CBZagQjAa3iYVFCp5")
//Transaction data could be any of the following 
// - address
cex.getBTCAddressTransaction(address).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Get recent transactions on a btc address deployed to ETH 
//limit is an integer indicating how deep the history should go
//..e,g limit of 1 means 1 result, 2 means 2 results.
cex.getPastBTCTransferEventsonETH(address, limit).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Get recent transactions on of USDT address deployed
// pipeline :
// ETH or BSC 
//limit is an integer indicating how deep the history should go
//..e,g limit of 1 means 1 result, 2 means 2 results.
cex.getRecentUSDTAddressTransactions(pipeline, address, limit).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Get recent transactions on a btc address deployed to BSC
//limit is an integer indicating how deep the history should go
//..e,g limit of 1 means last block.
cex.getPastBTCTransferEventsonBSC(address, limit).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Get recent transfer transactions of ETH address deployed to BSC 
//limit is an integer indicating how deep the history should go
//..e,g limit of 1 means 1 block.
cex.getPastBNBTransferEventsOnETH( address, limit).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Get recent transfer transactions of BNB address deployed to ETH
//limit is an integer indicating how deep the history should go
// ..e,g limit of 1 means 1 result, 2 means 2 results, and if it returns an empty array then the address has not perform any transaction within the blocks specify, use 0 to get all time transaction
cex.getPastETHTransferEventsOnBSC( address, limit).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Get recent transfer transactions that happened on BSC wallet
cex.getRecentBSCWalletTransactions(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Get recent transfer transactions that happened on ETH wallet
cex.getRecentETHWalletTransactions(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)

// Get recent transfer transactions that happened on  BTC wallet
cex.getRecentBTCWalletTransactions(wallet_name).then(
    (result) => {
        console.log(result)
    }
).catch(
    (err) => {
        console.error(err)
    }
)






```

<h2>Dependencies</h2>

* [bip39](https://www.npmjs.com/package/bip39): For mnemonic generation
* [hdkey](https://www.npmjs.com/package/hdkey): For implementation of BIP 32
* [ethereumjs-util](https://www.npmjs.com/package/ethereumjs-util)
* [axios](https://www.npmjs.com/package/axios): For making requests to API's
* [create-hash](https://www.npmjs.com/package/create-hash)
* [bs58check](https://www.npmjs.com/package/bs58check)
* [bitcore-lib](https://www.npmjs.com/package/bitcore-lib)

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