GithubHelp home page GithubHelp logo

mm-chain's Introduction

mm-chain

JavaScript blockchain example

Usage example

test.js

'use strict';

const BlockChain = require('./Blockchain');

let chain = new BlockChain();

chain.addBlock({
    sender: "Joker",
    recipient: "Batman",
    custom: 37
});

chain.addBlock({
    sender: "Monitor",
    recipient: "Flash",
    custom: 679
});

chain.addBlock({
    sender: "Arrow",
    recipient: "Diaz",
    custom: 907
});

console.log(JSON.stringify(chain.export(), null, 4));
console.log(chain.isValid());

output

[
    {
        "index": 0,
        "timestamp": "16:16:29 04/Aug/2020",
        "data": null,
        "previousHash": "0",
        "hash": "65045ee6815de81e87a3aac267fc3040f2c6ad3590f327c9480f96bf9558c13c",
        "referrer": 0
    },
    {
        "index": 1,
        "timestamp": "16:16:29 04/Aug/2020",
        "data": {
            "sender": "Joker",
            "recipient": "Batman",
            "custom": 37
        },
        "previousHash": "65045ee6815de81e87a3aac267fc3040f2c6ad3590f327c9480f96bf9558c13c",
        "hash": "52be8b575a80c68e8931eed933a9d7bb35776240b7b5893f49133d453f32ee99",
        "referrer": 44396
    },
    {
        "index": 2,
        "timestamp": "16:16:30 04/Aug/2020",
        "data": {
            "sender": "Monitor",
            "recipient": "Flash",
            "custom": 679
        },
        "previousHash": "52be8b575a80c68e8931eed933a9d7bb35776240b7b5893f49133d453f32ee99",
        "hash": "c097445682b8719020d99c9a3fca401d0edc4d0745a25f6e0c191b63c43e3fd0",
        "referrer": 18661
    },
    {
        "index": 3,
        "timestamp": "16:16:31 04/Aug/2020",
        "data": {
            "sender": "Arrow",
            "recipient": "Diaz",
            "custom": 907
        },
        "previousHash": "c097445682b8719020d99c9a3fca401d0edc4d0745a25f6e0c191b63c43e3fd0",
        "hash": "86bde52a16b7cd314762f643c399cfa0c12e6558d881f1ce72e92dd7d793cab9",
        "referrer": 13556
    }
]
true

Release History

  • 0.0.2 initial release

mm-chain's People

Contributors

dependabot[bot] avatar sinemah avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.