
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@d11k-ts/bitcoin
Advanced tools
@d11k-ts/bitcoinclient - Client for communicating with Bitcoin using BIP39
, bitcoinjs-lib and WIFtypes - TypeScript type definitions based on @d11k-ts/client and @d11k-ts/utilsutils - Utitilies for using haskoin and sochain endpoints in Bitcoin clientyarn add @d11k-ts/bitcoin
Following dependencies have to be installed into your project. These are not included in @d11k-ts/bitcoin.
yarn add axios@^0.27.2 coinselect
This package uses the following service providers:
| Function | Service | Notes |
|---|---|---|
| Balances | Sochain | https://chain.so/api/v2#get-balance |
| Transaction history | Sochain | https://chain.so/api/v2#get-display-data-address, https://chain.so/api/v2#get-tx |
| Transaction details by hash | Sochain | https://chain.so/api/v2#get-tx |
| Transaction fees | Bitgo | https://app.bitgo.com/docs/#operation/v2.tx.getfeeestimate |
| Transaction broadcast / utxos | Sochain / Haskoin | https://chain.so/api/v2#send-transaction, https://haskoin.ninerealms.com/btc |
| Explorer | Blockstream | https://blockstream.info |
Sochain API rate limits: https://chain.so/api/v2#rate-limits (300 requests/minute)
Bitgo API rate limits: https://app.bitgo.com/docs/#section/Rate-Limiting (10 requests/second)
Haskoin API : https://haskoin.ninerealms.com/btc
Mainnet//Imports
import {BTC_DECIMAL, BitcoinClient} from '@d11k-ts/bitcoin'
import {Network} from '@d11k-ts/client'
import {AssetBTC, assetAmount, assetToBase, baseToAsset} from '@d11k-ts/utils'
// Connect wallet to new btc client
const connectWallet = async () => {
let phrase = "phrase"
// Mainnet
const btcClient = new BitcoinClient({phrase})
// testnet
// const bnbClient = new BitcoinClient({ phrase, network: Network.Testnet })
let address = btcClient.getAddress()
console.log(`Asset Address is: ${address}`)
let balances = await btcClient.getBalance(address, [AssetBTC])
try {
let assetAmount = (baseToAsset(balances[0].amount)).amount()
console.log(`Asset address balance: ${assetAmount}`)
} catch (error) {
console.log('Address has no balance')
}
}
fastconst transfer = async () => {
// First initiate BitcoinClient
let amountToTransfer = 0.0001
let recipient = 'insert address'
let amount = assetToBase(assetAmount(amountToTransfer, BTC_DECIMAL))
try {
const txid = await btcClient.transfer({
asset: AssetBTC,
recipient: recipient,
amount: amount,
memo: "payment" // optional
})
console.log(`Amount: ${amount.amount().toString()} ${AssetBTC.symbol} Transaction id: ${txid}`)
} catch (error) {
console.log(`Transfer failed ${error}`)
}
}
//Returns FeeRates > this allows for dynamic feeRate adjustment on selection
const {fast, fastest, average} = await btcClient.getFeeRates()
try {
const txid = await btcClient.transfer({
'asset': AssetBTC,
'recipient': recipient,
'amount': amount,
'memo': "test transfer", // optional
feeRate: fast
})
console.log(`Amount ${baseToAsset(amount).amount()} ${AssetBTC.symbol} Transaction id ${txid}`)
} catch (error) {
console.log(`Transfer failed ${error}`)
}
//Get Fees - returns FeeOption & fee in BaseAmount
` Fees Fast: 0.00001 Fastest: 0.0000468 Average: 0.00001 `
try {
const {fast, fastest, average} = await btcClient.getFees()
console.log(`Fees Fast: ${baseToAsset(fast).amount()} Fastest: ${baseToAsset(fastest).amount()} Average: ${baseToAsset(average).amount()}`)
} catch (error) {
console.log(error)
}
//Get FeeRates - returns FeeOption & rate
` Fast: 12, Fastest 60, Average: 6 `
try {
const {fast, fastest, average} = await btcClient.getFeeRates()
console.log(`Fast: ${fast}, Fastest ${fastest}, Average: ${average}`)
} catch (error) {
console.log(error)
}
const transactionData = async () => {
let hash = "txhash string"
try {
const txData = await btcClient.getTransactionData(hash)
console.log(`From ${JSON.stringify(txData)}`)
} catch (error) {
console.log(`Error: ${error}`)
}
}
const transactionHistory = async () => {
// Retrieve transaction history for a set address
// txHistoryParams > address, offset, startTime, asset?
try {
const txHistory = await btcClient.getTransactions({address: Address, limit: 4})
console.log(`Found ${txHistory.total.toString()}`)
txHistory.txs.forEach(tx => console.log(tx))
} catch (error) {
console.log(`Error: ${error}`)
}
}
For sample code check out example test case in ./examples/test.ts
FAQs
bitcoin module for d11k chain
We found that @d11k-ts/bitcoin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.