Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Last active December 18, 2019 15:17
Show Gist options
  • Save ssaurel/9e1bafe7ccb174d973ee4176698dd218 to your computer and use it in GitHub Desktop.
Save ssaurel/9e1bafe7ccb174d973ee4176698dd218 to your computer and use it in GitHub Desktop.
Blockchain Implementation in JS by @ssaurel
var blockchain = new Blockchain(4);
var block1 = blockchain.newBlock("Second Block");
blockchain.addBlock(block1);
var block2 = blockchain.newBlock("Third Block");
blockchain.addBlock(block2);
var block3 = blockchain.newBlock("Fourth Block");
blockchain.addBlock(block3);
console.log("Blockchain Validity: " + blockchain.isBlockchainValid());
blockchain.display();
var block4 = new Block(12, "falseHash", Date.now(), "Block Invalid");
blockchain.addBlock(block4);
console.log("Blockchain Validity: " + blockchain.isBlockchainValid());
blockchain.display();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment