Thursday, February 6, 2025
\n
Blockchain {\n  chain: [\n    Block {\n      data: 'gen-data',\n      hash: 'gen-hash',\n      lastHash: 'gen-lastHash'\n    },\n    Block { data: 'one', hash: 'onegen-hash*', lastHash: 'gen-hash' },\n    Block {\n      data: 'two',\n      hash: 'twoonegen-hash**',\n      lastHash: 'onegen-hash*'\n    },\n    Block {\n      data: 'three',\n      hash: 'threetwoonegen-hash***',\n      lastHash: 'twoonegen-hash**'\n    },\n    Block {\n      data: 'four',\n      hash: 'fourthreetwoonegen-hash****',\n      lastHash: 'threetwoonegen-hash***'\n    },\n    Block {\n      data: 'five',\n      hash: 'fivefourthreetwoonegen-hash*****',\n      lastHash: 'fourthreetwoonegen-hash****'\n    },\n    Block {\n      data: 'six',\n      hash: 'sixfivefourthreetwoonegen-hash******',\n      lastHash: 'fivefourthreetwoonegen-hash*****'\n    },\n    Block {\n      data: 'seven',\n      hash: 'sevensixfivefourthreetwoonegen-hash*******',\n      lastHash: 'sixfivefourthreetwoonegen-hash******'\n    }\n  ]\n}\n<\/pre>\n\n\n\n

Happy Coding ...<\/p>\n","post_title":"A Walkthrough to Blockchain","post_excerpt":"Blockchain is a distributed & decentralized ledger that stores data and is publicly shared across all the node of its network. Blockchain is almost always used instead of the terms Bitcoin and cryptocurrency. And there are many other places this technology can be used. We are beginning to barely scratch the surface of it.With all the popularity around, we know that the Blockchain Technology is going to be huge. But what makes it unique?","post_status":"publish","comment_status":"open","ping_status":"open","post_password":"","post_name":"a-walkthrough-to-blockchain","to_ping":"","pinged":"","post_modified":"2024-11-14 04:21:15","post_modified_gmt":"2024-11-14 04:21:15","post_content_filtered":"","post_parent":0,"guid":"https:\/\/blogue.tech\/?p=280","menu_order":0,"post_type":"post","post_mime_type":"","comment_count":"0","filter":"raw"}],"next":false,"prev":false,"total_page":1},"paged":1,"column_class":"jeg_col_3o3","class":"jnews_block_3"};

\n

If you execute this file you'll get the following output:<\/p>\n\n\n\n

Blockchain {\n  chain: [\n    Block {\n      data: 'gen-data',\n      hash: 'gen-hash',\n      lastHash: 'gen-lastHash'\n    },\n    Block { data: 'one', hash: 'onegen-hash*', lastHash: 'gen-hash' },\n    Block {\n      data: 'two',\n      hash: 'twoonegen-hash**',\n      lastHash: 'onegen-hash*'\n    },\n    Block {\n      data: 'three',\n      hash: 'threetwoonegen-hash***',\n      lastHash: 'twoonegen-hash**'\n    },\n    Block {\n      data: 'four',\n      hash: 'fourthreetwoonegen-hash****',\n      lastHash: 'threetwoonegen-hash***'\n    },\n    Block {\n      data: 'five',\n      hash: 'fivefourthreetwoonegen-hash*****',\n      lastHash: 'fourthreetwoonegen-hash****'\n    },\n    Block {\n      data: 'six',\n      hash: 'sixfivefourthreetwoonegen-hash******',\n      lastHash: 'fivefourthreetwoonegen-hash*****'\n    },\n    Block {\n      data: 'seven',\n      hash: 'sevensixfivefourthreetwoonegen-hash*******',\n      lastHash: 'sixfivefourthreetwoonegen-hash******'\n    }\n  ]\n}\n<\/pre>\n\n\n\n

Happy Coding ...<\/p>\n","post_title":"A Walkthrough to Blockchain","post_excerpt":"Blockchain is a distributed & decentralized ledger that stores data and is publicly shared across all the node of its network. Blockchain is almost always used instead of the terms Bitcoin and cryptocurrency. And there are many other places this technology can be used. We are beginning to barely scratch the surface of it.With all the popularity around, we know that the Blockchain Technology is going to be huge. But what makes it unique?","post_status":"publish","comment_status":"open","ping_status":"open","post_password":"","post_name":"a-walkthrough-to-blockchain","to_ping":"","pinged":"","post_modified":"2024-11-14 04:21:15","post_modified_gmt":"2024-11-14 04:21:15","post_content_filtered":"","post_parent":0,"guid":"https:\/\/blogue.tech\/?p=280","menu_order":0,"post_type":"post","post_mime_type":"","comment_count":"0","filter":"raw"}],"next":false,"prev":false,"total_page":1},"paged":1,"column_class":"jeg_col_3o3","class":"jnews_block_3"};

\n
const simpleHash = (data) => {\n    \/\/simple hash function(not a cryptographic algorithm);return data + '*';\n}\n\n\nclass Block {\n    constructor (data , hash , lastHash){\n        \/\/data:what the block is storingthis.data = data;\/\/hash:generates unique string everytime with some cryptographic algorithmthis.hash = hash;\/\/lastHash:creates a link between new block and last blockthis.lastHash = lastHash;\n    }\n}\n\n\nclass Blockchain {\n    constructor() {\n        \/\/initial block for the chainconst genesis = new Block('gen-data' , 'gen-hash' , 'gen-lastHash');this.chain = [genesis];\n    }\n\/\/incoming blocks links to initial block\n    addBlock(data) {\n        const lastHash = this.chain[this.chain.length-1].hash;\n\n\n        const hash = simpleHash(data + lastHash);\n\n\n        const block = new Block(data ,hash , lastHash);\n\n\n        this.chain.push(block);\n    }\n}\n\n\nconst theBlockChain = new Blockchain();\ntheBlockChain.addBlock('one');\ntheBlockChain.addBlock('two');\ntheBlockChain.addBlock('three');\ntheBlockChain.addBlock('four');\ntheBlockChain.addBlock('five');\ntheBlockChain.addBlock('six');\ntheBlockChain.addBlock('seven');\n\n\nconsole.log(theBlockChain);\n\n\n<\/pre>\n\n\n\n

If you execute this file you'll get the following output:<\/p>\n\n\n\n

Blockchain {\n  chain: [\n    Block {\n      data: 'gen-data',\n      hash: 'gen-hash',\n      lastHash: 'gen-lastHash'\n    },\n    Block { data: 'one', hash: 'onegen-hash*', lastHash: 'gen-hash' },\n    Block {\n      data: 'two',\n      hash: 'twoonegen-hash**',\n      lastHash: 'onegen-hash*'\n    },\n    Block {\n      data: 'three',\n      hash: 'threetwoonegen-hash***',\n      lastHash: 'twoonegen-hash**'\n    },\n    Block {\n      data: 'four',\n      hash: 'fourthreetwoonegen-hash****',\n      lastHash: 'threetwoonegen-hash***'\n    },\n    Block {\n      data: 'five',\n      hash: 'fivefourthreetwoonegen-hash*****',\n      lastHash: 'fourthreetwoonegen-hash****'\n    },\n    Block {\n      data: 'six',\n      hash: 'sixfivefourthreetwoonegen-hash******',\n      lastHash: 'fivefourthreetwoonegen-hash*****'\n    },\n    Block {\n      data: 'seven',\n      hash: 'sevensixfivefourthreetwoonegen-hash*******',\n      lastHash: 'sixfivefourthreetwoonegen-hash******'\n    }\n  ]\n}\n<\/pre>\n\n\n\n

Happy Coding ...<\/p>\n","post_title":"A Walkthrough to Blockchain","post_excerpt":"Blockchain is a distributed & decentralized ledger that stores data and is publicly shared across all the node of its network. Blockchain is almost always used instead of the terms Bitcoin and cryptocurrency. And there are many other places this technology can be used. We are beginning to barely scratch the surface of it.With all the popularity around, we know that the Blockchain Technology is going to be huge. But what makes it unique?","post_status":"publish","comment_status":"open","ping_status":"open","post_password":"","post_name":"a-walkthrough-to-blockchain","to_ping":"","pinged":"","post_modified":"2024-11-14 04:21:15","post_modified_gmt":"2024-11-14 04:21:15","post_content_filtered":"","post_parent":0,"guid":"https:\/\/blogue.tech\/?p=280","menu_order":0,"post_type":"post","post_mime_type":"","comment_count":"0","filter":"raw"}],"next":false,"prev":false,"total_page":1},"paged":1,"column_class":"jeg_col_3o3","class":"jnews_block_3"};

\n

Create a file name index.js and paste the code below:<\/p>\n\n\n\n

const simpleHash = (data) => {\n    \/\/simple hash function(not a cryptographic algorithm);return data + '*';\n}\n\n\nclass Block {\n    constructor (data , hash , lastHash){\n        \/\/data:what the block is storingthis.data = data;\/\/hash:generates unique string everytime with some cryptographic algorithmthis.hash = hash;\/\/lastHash:creates a link between new block and last blockthis.lastHash = lastHash;\n    }\n}\n\n\nclass Blockchain {\n    constructor() {\n        \/\/initial block for the chainconst genesis = new Block('gen-data' , 'gen-hash' , 'gen-lastHash');this.chain = [genesis];\n    }\n\/\/incoming blocks links to initial block\n    addBlock(data) {\n        const lastHash = this.chain[this.chain.length-1].hash;\n\n\n        const hash = simpleHash(data + lastHash);\n\n\n        const block = new Block(data ,hash , lastHash);\n\n\n        this.chain.push(block);\n    }\n}\n\n\nconst theBlockChain = new Blockchain();\ntheBlockChain.addBlock('one');\ntheBlockChain.addBlock('two');\ntheBlockChain.addBlock('three');\ntheBlockChain.addBlock('four');\ntheBlockChain.addBlock('five');\ntheBlockChain.addBlock('six');\ntheBlockChain.addBlock('seven');\n\n\nconsole.log(theBlockChain);\n\n\n<\/pre>\n\n\n\n

If you execute this file you'll get the following output:<\/p>\n\n\n\n

Blockchain {\n  chain: [\n    Block {\n      data: 'gen-data',\n      hash: 'gen-hash',\n      lastHash: 'gen-lastHash'\n    },\n    Block { data: 'one', hash: 'onegen-hash*', lastHash: 'gen-hash' },\n    Block {\n      data: 'two',\n      hash: 'twoonegen-hash**',\n      lastHash: 'onegen-hash*'\n    },\n    Block {\n      data: 'three',\n      hash: 'threetwoonegen-hash***',\n      lastHash: 'twoonegen-hash**'\n    },\n    Block {\n      data: 'four',\n      hash: 'fourthreetwoonegen-hash****',\n      lastHash: 'threetwoonegen-hash***'\n    },\n    Block {\n      data: 'five',\n      hash: 'fivefourthreetwoonegen-hash*****',\n      lastHash: 'fourthreetwoonegen-hash****'\n    },\n    Block {\n      data: 'six',\n      hash: 'sixfivefourthreetwoonegen-hash******',\n      lastHash: 'fivefourthreetwoonegen-hash*****'\n    },\n    Block {\n      data: 'seven',\n      hash: 'sevensixfivefourthreetwoonegen-hash*******',\n      lastHash: 'sixfivefourthreetwoonegen-hash******'\n    }\n  ]\n}\n<\/pre>\n\n\n\n

Happy Coding ...<\/p>\n","post_title":"A Walkthrough to Blockchain","post_excerpt":"Blockchain is a distributed & decentralized ledger that stores data and is publicly shared across all the node of its network. Blockchain is almost always used instead of the terms Bitcoin and cryptocurrency. And there are many other places this technology can be used. We are beginning to barely scratch the surface of it.With all the popularity around, we know that the Blockchain Technology is going to be huge. But what makes it unique?","post_status":"publish","comment_status":"open","ping_status":"open","post_password":"","post_name":"a-walkthrough-to-blockchain","to_ping":"","pinged":"","post_modified":"2024-11-14 04:21:15","post_modified_gmt":"2024-11-14 04:21:15","post_content_filtered":"","post_parent":0,"guid":"https:\/\/blogue.tech\/?p=280","menu_order":0,"post_type":"post","post_mime_type":"","comment_count":"0","filter":"raw"}],"next":false,"prev":false,"total_page":1},"paged":1,"column_class":"jeg_col_3o3","class":"jnews_block_3"};

\n

Let's Code a Simple blockchain:<\/h2>\n\n\n\n

Create a file name index.js and paste the code below:<\/p>\n\n\n\n

const simpleHash = (data) => {\n    \/\/simple hash function(not a cryptographic algorithm);return data + '*';\n}\n\n\nclass Block {\n    constructor (data , hash , lastHash){\n        \/\/data:what the block is storingthis.data = data;\/\/hash:generates unique string everytime with some cryptographic algorithmthis.hash = hash;\/\/lastHash:creates a link between new block and last blockthis.lastHash = lastHash;\n    }\n}\n\n\nclass Blockchain {\n    constructor() {\n        \/\/initial block for the chainconst genesis = new Block('gen-data' , 'gen-hash' , 'gen-lastHash');this.chain = [genesis];\n    }\n\/\/incoming blocks links to initial block\n    addBlock(data) {\n        const lastHash = this.chain[this.chain.length-1].hash;\n\n\n        const hash = simpleHash(data + lastHash);\n\n\n        const block = new Block(data ,hash , lastHash);\n\n\n        this.chain.push(block);\n    }\n}\n\n\nconst theBlockChain = new Blockchain();\ntheBlockChain.addBlock('one');\ntheBlockChain.addBlock('two');\ntheBlockChain.addBlock('three');\ntheBlockChain.addBlock('four');\ntheBlockChain.addBlock('five');\ntheBlockChain.addBlock('six');\ntheBlockChain.addBlock('seven');\n\n\nconsole.log(theBlockChain);\n\n\n<\/pre>\n\n\n\n

If you execute this file you'll get the following output:<\/p>\n\n\n\n

Blockchain {\n  chain: [\n    Block {\n      data: 'gen-data',\n      hash: 'gen-hash',\n      lastHash: 'gen-lastHash'\n    },\n    Block { data: 'one', hash: 'onegen-hash*', lastHash: 'gen-hash' },\n    Block {\n      data: 'two',\n      hash: 'twoonegen-hash**',\n      lastHash: 'onegen-hash*'\n    },\n    Block {\n      data: 'three',\n      hash: 'threetwoonegen-hash***',\n      lastHash: 'twoonegen-hash**'\n    },\n    Block {\n      data: 'four',\n      hash: 'fourthreetwoonegen-hash****',\n      lastHash: 'threetwoonegen-hash***'\n    },\n    Block {\n      data: 'five',\n      hash: 'fivefourthreetwoonegen-hash*****',\n      lastHash: 'fourthreetwoonegen-hash****'\n    },\n    Block {\n      data: 'six',\n      hash: 'sixfivefourthreetwoonegen-hash******',\n      lastHash: 'fivefourthreetwoonegen-hash*****'\n    },\n    Block {\n      data: 'seven',\n      hash: 'sevensixfivefourthreetwoonegen-hash*******',\n      lastHash: 'sixfivefourthreetwoonegen-hash******'\n    }\n  ]\n}\n<\/pre>\n\n\n\n

Happy Coding ...<\/p>\n","post_title":"A Walkthrough to Blockchain","post_excerpt":"Blockchain is a distributed & decentralized ledger that stores data and is publicly shared across all the node of its network. Blockchain is almost always used instead of the terms Bitcoin and cryptocurrency. And there are many other places this technology can be used. We are beginning to barely scratch the surface of it.With all the popularity around, we know that the Blockchain Technology is going to be huge. But what makes it unique?","post_status":"publish","comment_status":"open","ping_status":"open","post_password":"","post_name":"a-walkthrough-to-blockchain","to_ping":"","pinged":"","post_modified":"2024-11-14 04:21:15","post_modified_gmt":"2024-11-14 04:21:15","post_content_filtered":"","post_parent":0,"guid":"https:\/\/blogue.tech\/?p=280","menu_order":0,"post_type":"post","post_mime_type":"","comment_count":"0","filter":"raw"}],"next":false,"prev":false,"total_page":1},"paged":1,"column_class":"jeg_col_3o3","class":"jnews_block_3"};

\n
  • Replicating that discrepancy across\u00a0all\u00a0<\/em>the versions of the ledger \u2013 the entire blockchain network \u2013 is such a huge task that it is computationally impractical, and would only happen if the bad guys suddenly had control over the\u00a0majority\u00a0<\/em>of the nodes mining blockchain and changed them all rather rapidly. This sort of coordinated attack on the majority of the nodes on the network is often called the\u00a051% attack.<\/li>\n<\/ul>\n\n\n\n

    Let's Code a Simple blockchain:<\/h2>\n\n\n\n

    Create a file name index.js and paste the code below:<\/p>\n\n\n\n

    const simpleHash = (data) => {\n    \/\/simple hash function(not a cryptographic algorithm);return data + '*';\n}\n\n\nclass Block {\n    constructor (data , hash , lastHash){\n        \/\/data:what the block is storingthis.data = data;\/\/hash:generates unique string everytime with some cryptographic algorithmthis.hash = hash;\/\/lastHash:creates a link between new block and last blockthis.lastHash = lastHash;\n    }\n}\n\n\nclass Blockchain {\n    constructor() {\n        \/\/initial block for the chainconst genesis = new Block('gen-data' , 'gen-hash' , 'gen-lastHash');this.chain = [genesis];\n    }\n\/\/incoming blocks links to initial block\n    addBlock(data) {\n        const lastHash = this.chain[this.chain.length-1].hash;\n\n\n        const hash = simpleHash(data + lastHash);\n\n\n        const block = new Block(data ,hash , lastHash);\n\n\n        this.chain.push(block);\n    }\n}\n\n\nconst theBlockChain = new Blockchain();\ntheBlockChain.addBlock('one');\ntheBlockChain.addBlock('two');\ntheBlockChain.addBlock('three');\ntheBlockChain.addBlock('four');\ntheBlockChain.addBlock('five');\ntheBlockChain.addBlock('six');\ntheBlockChain.addBlock('seven');\n\n\nconsole.log(theBlockChain);\n\n\n<\/pre>\n\n\n\n

    If you execute this file you'll get the following output:<\/p>\n\n\n\n

    Blockchain {\n  chain: [\n    Block {\n      data: 'gen-data',\n      hash: 'gen-hash',\n      lastHash: 'gen-lastHash'\n    },\n    Block { data: 'one', hash: 'onegen-hash*', lastHash: 'gen-hash' },\n    Block {\n      data: 'two',\n      hash: 'twoonegen-hash**',\n      lastHash: 'onegen-hash*'\n    },\n    Block {\n      data: 'three',\n      hash: 'threetwoonegen-hash***',\n      lastHash: 'twoonegen-hash**'\n    },\n    Block {\n      data: 'four',\n      hash: 'fourthreetwoonegen-hash****',\n      lastHash: 'threetwoonegen-hash***'\n    },\n    Block {\n      data: 'five',\n      hash: 'fivefourthreetwoonegen-hash*****',\n      lastHash: 'fourthreetwoonegen-hash****'\n    },\n    Block {\n      data: 'six',\n      hash: 'sixfivefourthreetwoonegen-hash******',\n      lastHash: 'fivefourthreetwoonegen-hash*****'\n    },\n    Block {\n      data: 'seven',\n      hash: 'sevensixfivefourthreetwoonegen-hash*******',\n      lastHash: 'sixfivefourthreetwoonegen-hash******'\n    }\n  ]\n}\n<\/pre>\n\n\n\n

    Happy Coding ...<\/p>\n","post_title":"A Walkthrough to Blockchain","post_excerpt":"Blockchain is a distributed & decentralized ledger that stores data and is publicly shared across all the node of its network. Blockchain is almost always used instead of the terms Bitcoin and cryptocurrency. And there are many other places this technology can be used. We are beginning to barely scratch the surface of it.With all the popularity around, we know that the Blockchain Technology is going to be huge. But what makes it unique?","post_status":"publish","comment_status":"open","ping_status":"open","post_password":"","post_name":"a-walkthrough-to-blockchain","to_ping":"","pinged":"","post_modified":"2024-11-14 04:21:15","post_modified_gmt":"2024-11-14 04:21:15","post_content_filtered":"","post_parent":0,"guid":"https:\/\/blogue.tech\/?p=280","menu_order":0,"post_type":"post","post_mime_type":"","comment_count":"0","filter":"raw"}],"next":false,"prev":false,"total_page":1},"paged":1,"column_class":"jeg_col_3o3","class":"jnews_block_3"};

    \n
  • Any naughty interception or change to one ledger (again, for example, where a block's hash doesn't tally) would immediately create a discrepancy with all the other versions. It would also have a shorter block \u201chistory\u201d to corroborate it, which makes that tampered version a suspicious character in the blockchain network where length matters .<\/li>\n\n\n\n
  • Replicating that discrepancy across\u00a0all\u00a0<\/em>the versions of the ledger \u2013 the entire blockchain network \u2013 is such a huge task that it is computationally impractical, and would only happen if the bad guys suddenly had control over the\u00a0majority\u00a0<\/em>of the nodes mining blockchain and changed them all rather rapidly. This sort of coordinated attack on the majority of the nodes on the network is often called the\u00a051% attack.<\/li>\n<\/ul>\n\n\n\n

    Let's Code a Simple blockchain:<\/h2>\n\n\n\n

    Create a file name index.js and paste the code below:<\/p>\n\n\n\n

    const simpleHash = (data) => {\n    \/\/simple hash function(not a cryptographic algorithm);return data + '*';\n}\n\n\nclass Block {\n    constructor (data , hash , lastHash){\n        \/\/data:what the block is storingthis.data = data;\/\/hash:generates unique string everytime with some cryptographic algorithmthis.hash = hash;\/\/lastHash:creates a link between new block and last blockthis.lastHash = lastHash;\n    }\n}\n\n\nclass Blockchain {\n    constructor() {\n        \/\/initial block for the chainconst genesis = new Block('gen-data' , 'gen-hash' , 'gen-lastHash');this.chain = [genesis];\n    }\n\/\/incoming blocks links to initial block\n    addBlock(data) {\n        const lastHash = this.chain[this.chain.length-1].hash;\n\n\n        const hash = simpleHash(data + lastHash);\n\n\n        const block = new Block(data ,hash , lastHash);\n\n\n        this.chain.push(block);\n    }\n}\n\n\nconst theBlockChain = new Blockchain();\ntheBlockChain.addBlock('one');\ntheBlockChain.addBlock('two');\ntheBlockChain.addBlock('three');\ntheBlockChain.addBlock('four');\ntheBlockChain.addBlock('five');\ntheBlockChain.addBlock('six');\ntheBlockChain.addBlock('seven');\n\n\nconsole.log(theBlockChain);\n\n\n<\/pre>\n\n\n\n

    If you execute this file you'll get the following output:<\/p>\n\n\n\n

    Blockchain {\n  chain: [\n    Block {\n      data: 'gen-data',\n      hash: 'gen-hash',\n      lastHash: 'gen-lastHash'\n    },\n    Block { data: 'one', hash: 'onegen-hash*', lastHash: 'gen-hash' },\n    Block {\n      data: 'two',\n      hash: 'twoonegen-hash**',\n      lastHash: 'onegen-hash*'\n    },\n    Block {\n      data: 'three',\n      hash: 'threetwoonegen-hash***',\n      lastHash: 'twoonegen-hash**'\n    },\n    Block {\n      data: 'four',\n      hash: 'fourthreetwoonegen-hash****',\n      lastHash: 'threetwoonegen-hash***'\n    },\n    Block {\n      data: 'five',\n      hash: 'fivefourthreetwoonegen-hash*****',\n      lastHash: 'fourthreetwoonegen-hash****'\n    },\n    Block {\n      data: 'six',\n      hash: 'sixfivefourthreetwoonegen-hash******',\n      lastHash: 'fivefourthreetwoonegen-hash*****'\n    },\n    Block {\n      data: 'seven',\n      hash: 'sevensixfivefourthreetwoonegen-hash*******',\n      lastHash: 'sixfivefourthreetwoonegen-hash******'\n    }\n  ]\n}\n<\/pre>\n\n\n\n

    Happy Coding ...<\/p>\n","post_title":"A Walkthrough to Blockchain","post_excerpt":"Blockchain is a distributed & decentralized ledger that stores data and is publicly shared across all the node of its network. Blockchain is almost always used instead of the terms Bitcoin and cryptocurrency. And there are many other places this technology can be used. We are beginning to barely scratch the surface of it.With all the popularity around, we know that the Blockchain Technology is going to be huge. But what makes it unique?","post_status":"publish","comment_status":"open","ping_status":"open","post_password":"","post_name":"a-walkthrough-to-blockchain","to_ping":"","pinged":"","post_modified":"2024-11-14 04:21:15","post_modified_gmt":"2024-11-14 04:21:15","post_content_filtered":"","post_parent":0,"guid":"https:\/\/blogue.tech\/?p=280","menu_order":0,"post_type":"post","post_mime_type":"","comment_count":"0","filter":"raw"}],"next":false,"prev":false,"total_page":1},"paged":1,"column_class":"jeg_col_3o3","class":"jnews_block_3"};

    \n
  • Where there are discrepancies in the ledger (for example the hash of a block doesn't match with the next block's reference to the previous block's hash), the ledger with the longest chain of valid transactions embedded will be the \u201ccorrect\u201d one \u2013 the source of truth. Any nodes working on other (shorter versions) of the chain switch to the longer one. This maintains the critical consensus (this bit is hugely oversimplified, but sufficient for now).<\/li>\n\n\n\n
  • Any naughty interception or change to one ledger (again, for example, where a block's hash doesn't tally) would immediately create a discrepancy with all the other versions. It would also have a shorter block \u201chistory\u201d to corroborate it, which makes that tampered version a suspicious character in the blockchain network where length matters .<\/li>\n\n\n\n
  • Replicating that discrepancy across\u00a0all\u00a0<\/em>the versions of the ledger \u2013 the entire blockchain network \u2013 is such a huge task that it is computationally impractical, and would only happen if the bad guys suddenly had control over the\u00a0majority\u00a0<\/em>of the nodes mining blockchain and changed them all rather rapidly. This sort of coordinated attack on the majority of the nodes on the network is often called the\u00a051% attack.<\/li>\n<\/ul>\n\n\n\n

    Let's Code a Simple blockchain:<\/h2>\n\n\n\n

    Create a file name index.js and paste the code below:<\/p>\n\n\n\n

    const simpleHash = (data) => {\n    \/\/simple hash function(not a cryptographic algorithm);return data + '*';\n}\n\n\nclass Block {\n    constructor (data , hash , lastHash){\n        \/\/data:what the block is storingthis.data = data;\/\/hash:generates unique string everytime with some cryptographic algorithmthis.hash = hash;\/\/lastHash:creates a link between new block and last blockthis.lastHash = lastHash;\n    }\n}\n\n\nclass Blockchain {\n    constructor() {\n        \/\/initial block for the chainconst genesis = new Block('gen-data' , 'gen-hash' , 'gen-lastHash');this.chain = [genesis];\n    }\n\/\/incoming blocks links to initial block\n    addBlock(data) {\n        const lastHash = this.chain[this.chain.length-1].hash;\n\n\n        const hash = simpleHash(data + lastHash);\n\n\n        const block = new Block(data ,hash , lastHash);\n\n\n        this.chain.push(block);\n    }\n}\n\n\nconst theBlockChain = new Blockchain();\ntheBlockChain.addBlock('one');\ntheBlockChain.addBlock('two');\ntheBlockChain.addBlock('three');\ntheBlockChain.addBlock('four');\ntheBlockChain.addBlock('five');\ntheBlockChain.addBlock('six');\ntheBlockChain.addBlock('seven');\n\n\nconsole.log(theBlockChain);\n\n\n<\/pre>\n\n\n\n

    If you execute this file you'll get the following output:<\/p>\n\n\n\n

    Blockchain {\n  chain: [\n    Block {\n      data: 'gen-data',\n      hash: 'gen-hash',\n      lastHash: 'gen-lastHash'\n    },\n    Block { data: 'one', hash: 'onegen-hash*', lastHash: 'gen-hash' },\n    Block {\n      data: 'two',\n      hash: 'twoonegen-hash**',\n      lastHash: 'onegen-hash*'\n    },\n    Block {\n      data: 'three',\n      hash: 'threetwoonegen-hash***',\n      lastHash: 'twoonegen-hash**'\n    },\n    Block {\n      data: 'four',\n      hash: 'fourthreetwoonegen-hash****',\n      lastHash: 'threetwoonegen-hash***'\n    },\n    Block {\n      data: 'five',\n      hash: 'fivefourthreetwoonegen-hash*****',\n      lastHash: 'fourthreetwoonegen-hash****'\n    },\n    Block {\n      data: 'six',\n      hash: 'sixfivefourthreetwoonegen-hash******',\n      lastHash: 'fivefourthreetwoonegen-hash*****'\n    },\n    Block {\n      data: 'seven',\n      hash: 'sevensixfivefourthreetwoonegen-hash*******',\n      lastHash: 'sixfivefourthreetwoonegen-hash******'\n    }\n  ]\n}\n<\/pre>\n\n\n\n

    Happy Coding ...<\/p>\n","post_title":"A Walkthrough to Blockchain","post_excerpt":"Blockchain is a distributed & decentralized ledger that stores data and is publicly shared across all the node of its network. Blockchain is almost always used instead of the terms Bitcoin and cryptocurrency. And there are many other places this technology can be used. We are beginning to barely scratch the surface of it.With all the popularity around, we know that the Blockchain Technology is going to be huge. But what makes it unique?","post_status":"publish","comment_status":"open","ping_status":"open","post_password":"","post_name":"a-walkthrough-to-blockchain","to_ping":"","pinged":"","post_modified":"2024-11-14 04:21:15","post_modified_gmt":"2024-11-14 04:21:15","post_content_filtered":"","post_parent":0,"guid":"https:\/\/blogue.tech\/?p=280","menu_order":0,"post_type":"post","post_mime_type":"","comment_count":"0","filter":"raw"}],"next":false,"prev":false,"total_page":1},"paged":1,"column_class":"jeg_col_3o3","class":"jnews_block_3"};

    \n
  • As hundreds become thousands of nodes (and more are added all the time), each node has to \u201cagree\u201d on the history of the blocks\/ledger \u2013 this is called \"critical consensus\". One of the ways in which consensus is achieved is through the cryptographic hash we talked about earlier.<\/li>\n\n\n\n
  • Where there are discrepancies in the ledger (for example the hash of a block doesn't match with the next block's reference to the previous block's hash), the ledger with the longest chain of valid transactions embedded will be the \u201ccorrect\u201d one \u2013 the source of truth. Any nodes working on other (shorter versions) of the chain switch to the longer one. This maintains the critical consensus (this bit is hugely oversimplified, but sufficient for now).<\/li>\n\n\n\n
  • Any naughty interception or change to one ledger (again, for example, where a block's hash doesn't tally) would immediately create a discrepancy with all the other versions. It would also have a shorter block \u201chistory\u201d to corroborate it, which makes that tampered version a suspicious character in the blockchain network where length matters .<\/li>\n\n\n\n
  • Replicating that discrepancy across\u00a0all\u00a0<\/em>the versions of the ledger \u2013 the entire blockchain network \u2013 is such a huge task that it is computationally impractical, and would only happen if the bad guys suddenly had control over the\u00a0majority\u00a0<\/em>of the nodes mining blockchain and changed them all rather rapidly. This sort of coordinated attack on the majority of the nodes on the network is often called the\u00a051% attack.<\/li>\n<\/ul>\n\n\n\n

    Let's Code a Simple blockchain:<\/h2>\n\n\n\n

    Create a file name index.js and paste the code below:<\/p>\n\n\n\n

    const simpleHash = (data) => {\n    \/\/simple hash function(not a cryptographic algorithm);return data + '*';\n}\n\n\nclass Block {\n    constructor (data , hash , lastHash){\n        \/\/data:what the block is storingthis.data = data;\/\/hash:generates unique string everytime with some cryptographic algorithmthis.hash = hash;\/\/lastHash:creates a link between new block and last blockthis.lastHash = lastHash;\n    }\n}\n\n\nclass Blockchain {\n    constructor() {\n        \/\/initial block for the chainconst genesis = new Block('gen-data' , 'gen-hash' , 'gen-lastHash');this.chain = [genesis];\n    }\n\/\/incoming blocks links to initial block\n    addBlock(data) {\n        const lastHash = this.chain[this.chain.length-1].hash;\n\n\n        const hash = simpleHash(data + lastHash);\n\n\n        const block = new Block(data ,hash , lastHash);\n\n\n        this.chain.push(block);\n    }\n}\n\n\nconst theBlockChain = new Blockchain();\ntheBlockChain.addBlock('one');\ntheBlockChain.addBlock('two');\ntheBlockChain.addBlock('three');\ntheBlockChain.addBlock('four');\ntheBlockChain.addBlock('five');\ntheBlockChain.addBlock('six');\ntheBlockChain.addBlock('seven');\n\n\nconsole.log(theBlockChain);\n\n\n<\/pre>\n\n\n\n

    If you execute this file you'll get the following output:<\/p>\n\n\n\n

    Blockchain {\n  chain: [\n    Block {\n      data: 'gen-data',\n      hash: 'gen-hash',\n      lastHash: 'gen-lastHash'\n    },\n    Block { data: 'one', hash: 'onegen-hash*', lastHash: 'gen-hash' },\n    Block {\n      data: 'two',\n      hash: 'twoonegen-hash**',\n      lastHash: 'onegen-hash*'\n    },\n    Block {\n      data: 'three',\n      hash: 'threetwoonegen-hash***',\n      lastHash: 'twoonegen-hash**'\n    },\n    Block {\n      data: 'four',\n      hash: 'fourthreetwoonegen-hash****',\n      lastHash: 'threetwoonegen-hash***'\n    },\n    Block {\n      data: 'five',\n      hash: 'fivefourthreetwoonegen-hash*****',\n      lastHash: 'fourthreetwoonegen-hash****'\n    },\n    Block {\n      data: 'six',\n      hash: 'sixfivefourthreetwoonegen-hash******',\n      lastHash: 'fivefourthreetwoonegen-hash*****'\n    },\n    Block {\n      data: 'seven',\n      hash: 'sevensixfivefourthreetwoonegen-hash*******',\n      lastHash: 'sixfivefourthreetwoonegen-hash******'\n    }\n  ]\n}\n<\/pre>\n\n\n\n

    Happy Coding ...<\/p>\n","post_title":"A Walkthrough to Blockchain","post_excerpt":"Blockchain is a distributed & decentralized ledger that stores data and is publicly shared across all the node of its network. Blockchain is almost always used instead of the terms Bitcoin and cryptocurrency. And there are many other places this technology can be used. We are beginning to barely scratch the surface of it.With all the popularity around, we know that the Blockchain Technology is going to be huge. But what makes it unique?","post_status":"publish","comment_status":"open","ping_status":"open","post_password":"","post_name":"a-walkthrough-to-blockchain","to_ping":"","pinged":"","post_modified":"2024-11-14 04:21:15","post_modified_gmt":"2024-11-14 04:21:15","post_content_filtered":"","post_parent":0,"guid":"https:\/\/blogue.tech\/?p=280","menu_order":0,"post_type":"post","post_mime_type":"","comment_count":"0","filter":"raw"}],"next":false,"prev":false,"total_page":1},"paged":1,"column_class":"jeg_col_3o3","class":"jnews_block_3"};

    \n
  • Each block in a chain has its own id - a cryptographic hash that is unique and specific to each block. That hash is also stored in the\u00a0next<\/em>\u00a0block in the chain, causing a link. A block can store thousands of transactions and the tiniest change in that block's data would result in a new hash. So if a hash changes but the next block has a different hash, then we know some data in the previous block was tampered with.<\/li>\n\n\n\n
  • As hundreds become thousands of nodes (and more are added all the time), each node has to \u201cagree\u201d on the history of the blocks\/ledger \u2013 this is called \"critical consensus\". One of the ways in which consensus is achieved is through the cryptographic hash we talked about earlier.<\/li>\n\n\n\n
  • Where there are discrepancies in the ledger (for example the hash of a block doesn't match with the next block's reference to the previous block's hash), the ledger with the longest chain of valid transactions embedded will be the \u201ccorrect\u201d one \u2013 the source of truth. Any nodes working on other (shorter versions) of the chain switch to the longer one. This maintains the critical consensus (this bit is hugely oversimplified, but sufficient for now).<\/li>\n\n\n\n
  • Any naughty interception or change to one ledger (again, for example, where a block's hash doesn't tally) would immediately create a discrepancy with all the other versions. It would also have a shorter block \u201chistory\u201d to corroborate it, which makes that tampered version a suspicious character in the blockchain network where length matters .<\/li>\n\n\n\n
  • Replicating that discrepancy across\u00a0all\u00a0<\/em>the versions of the ledger \u2013 the entire blockchain network \u2013 is such a huge task that it is computationally impractical, and would only happen if the bad guys suddenly had control over the\u00a0majority\u00a0<\/em>of the nodes mining blockchain and changed them all rather rapidly. This sort of coordinated attack on the majority of the nodes on the network is often called the\u00a051% attack.<\/li>\n<\/ul>\n\n\n\n

    Let's Code a Simple blockchain:<\/h2>\n\n\n\n

    Create a file name index.js and paste the code below:<\/p>\n\n\n\n

    const simpleHash = (data) => {\n    \/\/simple hash function(not a cryptographic algorithm);return data + '*';\n}\n\n\nclass Block {\n    constructor (data , hash , lastHash){\n        \/\/data:what the block is storingthis.data = data;\/\/hash:generates unique string everytime with some cryptographic algorithmthis.hash = hash;\/\/lastHash:creates a link between new block and last blockthis.lastHash = lastHash;\n    }\n}\n\n\nclass Blockchain {\n    constructor() {\n        \/\/initial block for the chainconst genesis = new Block('gen-data' , 'gen-hash' , 'gen-lastHash');this.chain = [genesis];\n    }\n\/\/incoming blocks links to initial block\n    addBlock(data) {\n        const lastHash = this.chain[this.chain.length-1].hash;\n\n\n        const hash = simpleHash(data + lastHash);\n\n\n        const block = new Block(data ,hash , lastHash);\n\n\n        this.chain.push(block);\n    }\n}\n\n\nconst theBlockChain = new Blockchain();\ntheBlockChain.addBlock('one');\ntheBlockChain.addBlock('two');\ntheBlockChain.addBlock('three');\ntheBlockChain.addBlock('four');\ntheBlockChain.addBlock('five');\ntheBlockChain.addBlock('six');\ntheBlockChain.addBlock('seven');\n\n\nconsole.log(theBlockChain);\n\n\n<\/pre>\n\n\n\n

    If you execute this file you'll get the following output:<\/p>\n\n\n\n

    Blockchain {\n  chain: [\n    Block {\n      data: 'gen-data',\n      hash: 'gen-hash',\n      lastHash: 'gen-lastHash'\n    },\n    Block { data: 'one', hash: 'onegen-hash*', lastHash: 'gen-hash' },\n    Block {\n      data: 'two',\n      hash: 'twoonegen-hash**',\n      lastHash: 'onegen-hash*'\n    },\n    Block {\n      data: 'three',\n      hash: 'threetwoonegen-hash***',\n      lastHash: 'twoonegen-hash**'\n    },\n    Block {\n      data: 'four',\n      hash: 'fourthreetwoonegen-hash****',\n      lastHash: 'threetwoonegen-hash***'\n    },\n    Block {\n      data: 'five',\n      hash: 'fivefourthreetwoonegen-hash*****',\n      lastHash: 'fourthreetwoonegen-hash****'\n    },\n    Block {\n      data: 'six',\n      hash: 'sixfivefourthreetwoonegen-hash******',\n      lastHash: 'fivefourthreetwoonegen-hash*****'\n    },\n    Block {\n      data: 'seven',\n      hash: 'sevensixfivefourthreetwoonegen-hash*******',\n      lastHash: 'sixfivefourthreetwoonegen-hash******'\n    }\n  ]\n}\n<\/pre>\n\n\n\n

    Happy Coding ...<\/p>\n","post_title":"A Walkthrough to Blockchain","post_excerpt":"Blockchain is a distributed & decentralized ledger that stores data and is publicly shared across all the node of its network. Blockchain is almost always used instead of the terms Bitcoin and cryptocurrency. And there are many other places this technology can be used. We are beginning to barely scratch the surface of it.With all the popularity around, we know that the Blockchain Technology is going to be huge. But what makes it unique?","post_status":"publish","comment_status":"open","ping_status":"open","post_password":"","post_name":"a-walkthrough-to-blockchain","to_ping":"","pinged":"","post_modified":"2024-11-14 04:21:15","post_modified_gmt":"2024-11-14 04:21:15","post_content_filtered":"","post_parent":0,"guid":"https:\/\/blogue.tech\/?p=280","menu_order":0,"post_type":"post","post_mime_type":"","comment_count":"0","filter":"raw"}],"next":false,"prev":false,"total_page":1},"paged":1,"column_class":"jeg_col_3o3","class":"jnews_block_3"};

    \n
  • Chains of digitally encrypted and timestamped records of transactions are lumped into \u201cblocks\u201d, which are maintained on a \u201cledger\u201d by each node. As transactions are added to a block, and blocks are linked together linearly and chronologically as \"chains\". Then the entire record\/ledger gets synchronised across the network of nodes such that all the block \"chains\" on the nodes should tell an identical story of the history of any given transaction. Thus we get \"block + chain = blockchain\". It's a long, complicated linked list.<\/li>\n\n\n\n
  • Each block in a chain has its own id - a cryptographic hash that is unique and specific to each block. That hash is also stored in the\u00a0next<\/em>\u00a0block in the chain, causing a link. A block can store thousands of transactions and the tiniest change in that block's data would result in a new hash. So if a hash changes but the next block has a different hash, then we know some data in the previous block was tampered with.<\/li>\n\n\n\n
  • As hundreds become thousands of nodes (and more are added all the time), each node has to \u201cagree\u201d on the history of the blocks\/ledger \u2013 this is called \"critical consensus\". One of the ways in which consensus is achieved is through the cryptographic hash we talked about earlier.<\/li>\n\n\n\n
  • Where there are discrepancies in the ledger (for example the hash of a block doesn't match with the next block's reference to the previous block's hash), the ledger with the longest chain of valid transactions embedded will be the \u201ccorrect\u201d one \u2013 the source of truth. Any nodes working on other (shorter versions) of the chain switch to the longer one. This maintains the critical consensus (this bit is hugely oversimplified, but sufficient for now).<\/li>\n\n\n\n
  • Any naughty interception or change to one ledger (again, for example, where a block's hash doesn't tally) would immediately create a discrepancy with all the other versions. It would also have a shorter block \u201chistory\u201d to corroborate it, which makes that tampered version a suspicious character in the blockchain network where length matters .<\/li>\n\n\n\n
  • Replicating that discrepancy across\u00a0all\u00a0<\/em>the versions of the ledger \u2013 the entire blockchain network \u2013 is such a huge task that it is computationally impractical, and would only happen if the bad guys suddenly had control over the\u00a0majority\u00a0<\/em>of the nodes mining blockchain and changed them all rather rapidly. This sort of coordinated attack on the majority of the nodes on the network is often called the\u00a051% attack.<\/li>\n<\/ul>\n\n\n\n

    Let's Code a Simple blockchain:<\/h2>\n\n\n\n

    Create a file name index.js and paste the code below:<\/p>\n\n\n\n

    const simpleHash = (data) => {\n    \/\/simple hash function(not a cryptographic algorithm);return data + '*';\n}\n\n\nclass Block {\n    constructor (data , hash , lastHash){\n        \/\/data:what the block is storingthis.data = data;\/\/hash:generates unique string everytime with some cryptographic algorithmthis.hash = hash;\/\/lastHash:creates a link between new block and last blockthis.lastHash = lastHash;\n    }\n}\n\n\nclass Blockchain {\n    constructor() {\n        \/\/initial block for the chainconst genesis = new Block('gen-data' , 'gen-hash' , 'gen-lastHash');this.chain = [genesis];\n    }\n\/\/incoming blocks links to initial block\n    addBlock(data) {\n        const lastHash = this.chain[this.chain.length-1].hash;\n\n\n        const hash = simpleHash(data + lastHash);\n\n\n        const block = new Block(data ,hash , lastHash);\n\n\n        this.chain.push(block);\n    }\n}\n\n\nconst theBlockChain = new Blockchain();\ntheBlockChain.addBlock('one');\ntheBlockChain.addBlock('two');\ntheBlockChain.addBlock('three');\ntheBlockChain.addBlock('four');\ntheBlockChain.addBlock('five');\ntheBlockChain.addBlock('six');\ntheBlockChain.addBlock('seven');\n\n\nconsole.log(theBlockChain);\n\n\n<\/pre>\n\n\n\n

    If you execute this file you'll get the following output:<\/p>\n\n\n\n

    Blockchain {\n  chain: [\n    Block {\n      data: 'gen-data',\n      hash: 'gen-hash',\n      lastHash: 'gen-lastHash'\n    },\n    Block { data: 'one', hash: 'onegen-hash*', lastHash: 'gen-hash' },\n    Block {\n      data: 'two',\n      hash: 'twoonegen-hash**',\n      lastHash: 'onegen-hash*'\n    },\n    Block {\n      data: 'three',\n      hash: 'threetwoonegen-hash***',\n      lastHash: 'twoonegen-hash**'\n    },\n    Block {\n      data: 'four',\n      hash: 'fourthreetwoonegen-hash****',\n      lastHash: 'threetwoonegen-hash***'\n    },\n    Block {\n      data: 'five',\n      hash: 'fivefourthreetwoonegen-hash*****',\n      lastHash: 'fourthreetwoonegen-hash****'\n    },\n    Block {\n      data: 'six',\n      hash: 'sixfivefourthreetwoonegen-hash******',\n      lastHash: 'fivefourthreetwoonegen-hash*****'\n    },\n    Block {\n      data: 'seven',\n      hash: 'sevensixfivefourthreetwoonegen-hash*******',\n      lastHash: 'sixfivefourthreetwoonegen-hash******'\n    }\n  ]\n}\n<\/pre>\n\n\n\n

    Happy Coding ...<\/p>\n","post_title":"A Walkthrough to Blockchain","post_excerpt":"Blockchain is a distributed & decentralized ledger that stores data and is publicly shared across all the node of its network. Blockchain is almost always used instead of the terms Bitcoin and cryptocurrency. And there are many other places this technology can be used. We are beginning to barely scratch the surface of it.With all the popularity around, we know that the Blockchain Technology is going to be huge. But what makes it unique?","post_status":"publish","comment_status":"open","ping_status":"open","post_password":"","post_name":"a-walkthrough-to-blockchain","to_ping":"","pinged":"","post_modified":"2024-11-14 04:21:15","post_modified_gmt":"2024-11-14 04:21:15","post_content_filtered":"","post_parent":0,"guid":"https:\/\/blogue.tech\/?p=280","menu_order":0,"post_type":"post","post_mime_type":"","comment_count":"0","filter":"raw"}],"next":false,"prev":false,"total_page":1},"paged":1,"column_class":"jeg_col_3o3","class":"jnews_block_3"};

    \n
  • Blockchains are \u2018mined\u201d (produced through the expenditure of effort, like in gold mining) by powerful and resource-hungry computers\u00a0\u2013 called nodes, that are on the same network.<\/li>\n\n\n\n
  • Chains of digitally encrypted and timestamped records of transactions are lumped into \u201cblocks\u201d, which are maintained on a \u201cledger\u201d by each node. As transactions are added to a block, and blocks are linked together linearly and chronologically as \"chains\". Then the entire record\/ledger gets synchronised across the network of nodes such that all the block \"chains\" on the nodes should tell an identical story of the history of any given transaction. Thus we get \"block + chain = blockchain\". It's a long, complicated linked list.<\/li>\n\n\n\n
  • Each block in a chain has its own id - a cryptographic hash that is unique and specific to each block. That hash is also stored in the\u00a0next<\/em>\u00a0block in the chain, causing a link. A block can store thousands of transactions and the tiniest change in that block's data would result in a new hash. So if a hash changes but the next block has a different hash, then we know some data in the previous block was tampered with.<\/li>\n\n\n\n
  • As hundreds become thousands of nodes (and more are added all the time), each node has to \u201cagree\u201d on the history of the blocks\/ledger \u2013 this is called \"critical consensus\". One of the ways in which consensus is achieved is through the cryptographic hash we talked about earlier.<\/li>\n\n\n\n
  • Where there are discrepancies in the ledger (for example the hash of a block doesn't match with the next block's reference to the previous block's hash), the ledger with the longest chain of valid transactions embedded will be the \u201ccorrect\u201d one \u2013 the source of truth. Any nodes working on other (shorter versions) of the chain switch to the longer one. This maintains the critical consensus (this bit is hugely oversimplified, but sufficient for now).<\/li>\n\n\n\n
  • Any naughty interception or change to one ledger (again, for example, where a block's hash doesn't tally) would immediately create a discrepancy with all the other versions. It would also have a shorter block \u201chistory\u201d to corroborate it, which makes that tampered version a suspicious character in the blockchain network where length matters .<\/li>\n\n\n\n
  • Replicating that discrepancy across\u00a0all\u00a0<\/em>the versions of the ledger \u2013 the entire blockchain network \u2013 is such a huge task that it is computationally impractical, and would only happen if the bad guys suddenly had control over the\u00a0majority\u00a0<\/em>of the nodes mining blockchain and changed them all rather rapidly. This sort of coordinated attack on the majority of the nodes on the network is often called the\u00a051% attack.<\/li>\n<\/ul>\n\n\n\n

    Let's Code a Simple blockchain:<\/h2>\n\n\n\n

    Create a file name index.js and paste the code below:<\/p>\n\n\n\n

    const simpleHash = (data) => {\n    \/\/simple hash function(not a cryptographic algorithm);return data + '*';\n}\n\n\nclass Block {\n    constructor (data , hash , lastHash){\n        \/\/data:what the block is storingthis.data = data;\/\/hash:generates unique string everytime with some cryptographic algorithmthis.hash = hash;\/\/lastHash:creates a link between new block and last blockthis.lastHash = lastHash;\n    }\n}\n\n\nclass Blockchain {\n    constructor() {\n        \/\/initial block for the chainconst genesis = new Block('gen-data' , 'gen-hash' , 'gen-lastHash');this.chain = [genesis];\n    }\n\/\/incoming blocks links to initial block\n    addBlock(data) {\n        const lastHash = this.chain[this.chain.length-1].hash;\n\n\n        const hash = simpleHash(data + lastHash);\n\n\n        const block = new Block(data ,hash , lastHash);\n\n\n        this.chain.push(block);\n    }\n}\n\n\nconst theBlockChain = new Blockchain();\ntheBlockChain.addBlock('one');\ntheBlockChain.addBlock('two');\ntheBlockChain.addBlock('three');\ntheBlockChain.addBlock('four');\ntheBlockChain.addBlock('five');\ntheBlockChain.addBlock('six');\ntheBlockChain.addBlock('seven');\n\n\nconsole.log(theBlockChain);\n\n\n<\/pre>\n\n\n\n

    If you execute this file you'll get the following output:<\/p>\n\n\n\n

    Blockchain {\n  chain: [\n    Block {\n      data: 'gen-data',\n      hash: 'gen-hash',\n      lastHash: 'gen-lastHash'\n    },\n    Block { data: 'one', hash: 'onegen-hash*', lastHash: 'gen-hash' },\n    Block {\n      data: 'two',\n      hash: 'twoonegen-hash**',\n      lastHash: 'onegen-hash*'\n    },\n    Block {\n      data: 'three',\n      hash: 'threetwoonegen-hash***',\n      lastHash: 'twoonegen-hash**'\n    },\n    Block {\n      data: 'four',\n      hash: 'fourthreetwoonegen-hash****',\n      lastHash: 'threetwoonegen-hash***'\n    },\n    Block {\n      data: 'five',\n      hash: 'fivefourthreetwoonegen-hash*****',\n      lastHash: 'fourthreetwoonegen-hash****'\n    },\n    Block {\n      data: 'six',\n      hash: 'sixfivefourthreetwoonegen-hash******',\n      lastHash: 'fivefourthreetwoonegen-hash*****'\n    },\n    Block {\n      data: 'seven',\n      hash: 'sevensixfivefourthreetwoonegen-hash*******',\n      lastHash: 'sixfivefourthreetwoonegen-hash******'\n    }\n  ]\n}\n<\/pre>\n\n\n\n

    Happy Coding ...<\/p>\n","post_title":"A Walkthrough to Blockchain","post_excerpt":"Blockchain is a distributed & decentralized ledger that stores data and is publicly shared across all the node of its network. Blockchain is almost always used instead of the terms Bitcoin and cryptocurrency. And there are many other places this technology can be used. We are beginning to barely scratch the surface of it.With all the popularity around, we know that the Blockchain Technology is going to be huge. But what makes it unique?","post_status":"publish","comment_status":"open","ping_status":"open","post_password":"","post_name":"a-walkthrough-to-blockchain","to_ping":"","pinged":"","post_modified":"2024-11-14 04:21:15","post_modified_gmt":"2024-11-14 04:21:15","post_content_filtered":"","post_parent":0,"guid":"https:\/\/blogue.tech\/?p=280","menu_order":0,"post_type":"post","post_mime_type":"","comment_count":"0","filter":"raw"}],"next":false,"prev":false,"total_page":1},"paged":1,"column_class":"jeg_col_3o3","class":"jnews_block_3"};

    \n