0.0.4 • Published 2 years ago

cexdb v0.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago
npm i cexdb
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)
    }
)