1.0.23 • Published 6 years ago

doxie-chain v1.0.23

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

Doxie Chain

A lightweight Blockchain built in JS

Usage

To add to a dependency to your project:

npm install doxie-chain --save

Import/Require It

import { Block, Blockchain } from doxie-chain or

const { Block, Blockchain } = require('doxie-chain');

Now Creating a Chain

const blockchain = new Blockchain();

  blockchain.addBlock(new Block('Bear'))
  blockchain.addBlock(new Block('Walter'))
  blockchain.addBlock(new Block('Wrigley))

Block contains the properties:

const block = new Block('Batman')
block.hash = //SHA256 hash of ${block.previouHash}$""{'Batman'}
block.previousHash = // SHA256 hash of the previous block's hash in the chain, changing this will change the hash.
block.data = 'Batman'

To inspect your chain

blockchain.chain === // Array of your Blocks ex: [Block(), Block()]

To validate your Blockchain: blockchain.isValid() // Returns True or False, if your chain or data was mainupulated this will return False.

And thats it!

Special thanks to chainshot.com for writing some great tests

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago