Skip to content

Instantly share code, notes, and snippets.

@ssaurel ssaurel/
Last active Jan 21, 2018

What would you like to do?
Blockchain in action for a tutorial on
package fr.toutsurlebitcoin.myblockchain;
public class Main {
public static void main(String[] args) {
Blockchain blockchain = new Blockchain(4);
blockchain.addBlock(blockchain.newBlock("Tout sur le Bitcoin"));
blockchain.addBlock(blockchain.newBlock("Sylvain Saurel"));
System.out.println("Blockchain valid ? " + blockchain.isBlockChainValid());
// add an invalid block to corrupt Blockchain
blockchain.addBlock(new Block(15, System.currentTimeMillis(), "aaaabbb", "Block invalid"));
System.out.println("Blockchain valid ? " + blockchain.isBlockChainValid());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.