npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ivandurak0/blockchain-api

v0.0.5

Published

Simple and easy lib to work with blockchain api and all kind of cryptocurrencies.

Downloads

7

Readme

blockchain-api

Description

Blockchain API provides easy and understandable way to work with blockchain.

You can create / send transactions, generate wallets (now only BTC and LTC), check balance and much more.

Install

The blockchain-api library is exported as a npm module.

$ npm install @ivandurak0/blockchain-api

Usage

To use this lib you need to run blockchain service first.

Bitcoin full node now is about 300GB total, but for some operations it is enough to run it in pruned mode (with this option you can decrease disk usage up to 10GB)

After you have your favorite blockchain running on your server, using this lib becomes easy

// Import blockchain api class in your module
const BlockChainApi = require('@ivandurak0/blockchain-api');

// Create instance of api class
// host - host of server where your blockchain is running
// port - port on which blockchain is listening for api calls
// username - user specified in config file of your blockchain service
// password - password
const blockchainApi = new BlockChainApi('host', 'port', 'username', 'password');

Example of creating BTC wallet

// Raw private key
// Must be secret!!!
const rawPrivateKey = blockchainApi.getRawPrivateKey();

// Encoded private key in Wallet Import Format
// Used to sign your transactions, import your wallet somewhere
// Don't tell it anyone!!! It must be secret to prevent losing money from your wallet
const privateKey = blockchainApi.getPrivateKeyBTC(rawPrivateKey);

// Address is used to get and store your crypto currency
// You can tell it to your friends so that they could transfer money to you
const addressBTC = blockchainApi.getAddressBTC(rawPrivateKey);

Example of sending transaction

// In this example we will transfer all money from one wallet to another


// Get all unspent transactions from wallet
blockchainApi.listUnspent([1, 9999999, ["your_first_wallet_address"]], (response) => {
    if(response.error) {
        console.log("An error occured", response.error);
        return;
    }
    
    let totalAmount = 0;
    const inputs = [];
    const output = {};
    
    // Transactions with 6+ confirmations are considered safe
    response.result.filter(t => t.confirmations >= 6).forEach((t) => {
       totalAmount += t.amount;
       inputs.push({
           txid: t.txid,
           vout: t.vout
       });
    });
    
    // 2% of total amount are used as a transaction fee, you can use any other amount if you want
    output["your_second_wallet_address"] = (totalAmount * 0.98).toFixed(8);
   
    blockchainApi.createRawTransaction([inputs, output], (rawTransaction) => {
        if(!rawTransaction.result) {
            console.log("An error occured");
            return;
        }
        blockchainApi.signRawTransactionWithKey([rawTransaction.result, ["your_first_wallet_private_wif"]],
            (signedTransaction) => {
                if (!signedTransaction.result) {
                    console.log("An error occured");
                    return;
                }
                blockchainApi.sendRawTransaction([signedTransaction.result.hex], (transaction) => {
                    console.log("Success!!!", transaction);
                });
            });
    });
});

Support

You can support this project and transfer BTC to this address:

1NBAH44o8zCY4WXQnpnksk1JjE6aPu9BfC