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 🙏

© 2024 – Pkg Stats / Ryan Hefner

izigma-blockchain

v2.0.1

Published

This is a blockchain freamwork to build blockchain networks

Downloads

3

Readme

iZigma Blockchain

This is a blockchain library that can be used to create a complete blockchain network with multiple blockchain support. To launch a you only need to create a object in your project using the library. If you want more blockchains, create more objects. To mine blocks, read the chain or to create trasacations use the methods binded to the object. Complete method list can be obtain by reading the index.js file of the library.

Configuration

To use or test this library you need to add a configuration file. Create a file named izigma-config.js on the project root directory.

Then past the following code

const DIFFICULTY = 2;
const MINE_RATE = 1000;
const INITIAL_BALANCE = 500;
const MINING_REWARD = 50;
module.exports = { DIFFICULTY,MINE_RATE,INITIAL_BALANCE,MINING_REWARD};

Here the DIFFICULTY attribute is the initial difficulty for the proof of work consesus. MINE_RATE is the how often a block is created in the mine in mille seconds. INITIAL_BALANCE hold the wallate balance of the node. And MINING_REWARD is the reward recives for the miner for doing mining works...

Method List

  • addBlock(data) -> add a new block to the chain without mining.
  • getChain() -> Read the blockchain.
  • isValidChain(chain) -> Check incoming chain from the network is valid compaird to the current blockchain
  • replaceChain(newChain) -> Replace the current chain with a new chain
  • getChainFileName() -> geth the blockchain file name
  • calculateBlockchainHash() -> calculate a hash value for the whole chain
  • createWallet(publicKey, privateKey, algorithm) -> use only when you need to change the wallet.if not auto generated wallet is there,keys generated with RSA algorithm
  • createTransaction(recipient, amount) -> create a new transaction
  • createRecord(data) -> create a new record
  • calculateBalance() -> calculate the wallet balance for the chain
  • calculateSpecialCoinBalance(coin) -> calculate the balance for a customly generated coin
  • getPublicKey() -> Get the public key of the node
  • isContributed() -> Check is there any previous transactions
  • getTransactionPool() -> get the transactions in the transaction pool
  • clearTransactionPool() -> clear transaction pool
  • updateOrAddTransactionToTransactionPool(transaction) -> add or update existing transaction in the pool
  • getSpecialCoinTransactionPool() -> get the custom coin transactions in the transaction pool
  • clearSpecialCoinTransactionPool() -> clear special coin transactions in the pool
  • updateOrAddTransactionToSpecialCoinTransactionPool(transaction) -> add or update existing custom coin transaction in the pool
  • getRecordPool() -> get the current record pool
  • clearRecordPool() -> clear the current record pool
  • addRecordToRecordPool() -> add record to the the record pool
  • mineTransactions() -> mine the transaction
  • mineRecords() -> mine the records
  • generateSpecailCoinandDeploy(recivers, coinsForEachReciver, coinName) -> create and deploy a custome coin to the blockchain

Samaple Code

const express = require ('express');
const bodyParser = require('body-parser');
const Blockchain = require('izigma-blockchain');

const HTTP_PORT = process.env.HTTP_PORT || 3001;

const app = express();
//To work with more chains create more objects like chain_2,chain_3
const chain = new Blockchain();
chain.createWallet();
app.use(bodyParser.json());

app.get('/blocks',async(req,res) =>{
    let blockchain = await chain.getChain();
    res.json(blockchain);
});

app.post('/mine',async(req,res) =>{
    const block = await chain.addBlock(req.body.data);
    console.log(`New block added : ${ block.toString()}`);

    let blockchain = await chain.getChain();

    res.redirect('/blocks');
});

app.get('/transactions',(req,res)=>{
    res.json(chain.getTransactionPool());
})

app.post('/transact',(req,res)=>{
    const {recipient, amount} = req.body;
    const transaction = chain.createTransaction(recipient,amount);
    res.redirect('/transactions');
});

app.get('/mine-transactions',(req,res)=>{
    const block = chain.mineTransaction();
    chain.clearTransactionPool();
    console.log(`New block added : ${block.toString()}`);
    res.redirect('/blocks');
});

app.get('/public-key',(req,res)=>{
    res.json({
        publicKey: chain.getPublicKey()
    });
})

app.listen(HTTP_PORT, async () => {
  console.log(`Listeing on port ${HTTP_PORT}`);
});