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\nHappy 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"};
\nconst 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\nIf 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\nHappy 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"};
\nCreate 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\nIf 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\nHappy 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"};
\nLet'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\nIf 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\nHappy 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\nIf 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\nHappy 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\nIf 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\nHappy 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\nIf 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\nHappy 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\nIf 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\nHappy 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\nIf 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\nHappy 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\nIf 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\nHappy 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\nIf 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\nHappy 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\nIf 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\nHappy 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"};
\nSo the key principles are:<\/p>\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\nIf 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\nHappy 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"};
\nIt is essential to remember that the blockchain is a technology \u2013 mathematically complex software code to be specific. And Bitcoin (or Ethereum or any of the other cryptos on offer) are just applications of that technology.<\/p>\n\n\n\n
So the key principles are:<\/p>\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\nIf 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\nHappy 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"};
\nHow Blockchain works?<\/strong><\/h2>\n\n\n\n
It is essential to remember that the blockchain is a technology \u2013 mathematically complex software code to be specific. And Bitcoin (or Ethereum or any of the other cryptos on offer) are just applications of that technology.<\/p>\n\n\n\n
So the key principles are:<\/p>\n\n\n\n
\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\nIf 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\nHappy 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"};
\nSo it\u2019s a big problem really \u2013 modern life requires that we rely on, trust in and pay for \u201ctrusted\u201d third party intermediaries to ensure that value (money) does actually digitally \u201cchange hands\u201d. That is why Visa and MasterCard exist, and why PayPal and others link with your bank accounts.<\/p>\n\n\n\n
How Blockchain works?<\/strong><\/h2>\n\n\n\n
It is essential to remember that the blockchain is a technology \u2013 mathematically complex software code to be specific. And Bitcoin (or Ethereum or any of the other cryptos on offer) are just applications of that technology.<\/p>\n\n\n\n
So the key principles are:<\/p>\n\n\n\n
\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\nIf 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\nHappy 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"};
\nThis is technically called the \u201cdouble spending problem<\/a>\u201d \u2013 how do you ensure that you\u2019re not spending the same money twice? Without someone to do this, you could spend money and at the same time continue to hold on to that money.<\/p>\n\n\n\n
So it\u2019s a big problem really \u2013 modern life requires that we rely on, trust in and pay for \u201ctrusted\u201d third party intermediaries to ensure that value (money) does actually digitally \u201cchange hands\u201d. That is why Visa and MasterCard exist, and why PayPal and others link with your bank accounts.<\/p>\n\n\n\n
How Blockchain works?<\/strong><\/h2>\n\n\n\n
It is essential to remember that the blockchain is a technology \u2013 mathematically complex software code to be specific. And Bitcoin (or Ethereum or any of the other cryptos on offer) are just applications of that technology.<\/p>\n\n\n\n
So the key principles are:<\/p>\n\n\n\n
\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\nIf 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\nHappy 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"};
\nThat is why you need financial intermediaries to ensure that when you buy your CR7 Jersey, using a credit card, the money (value) is \u201cremoved\u201d from your account and \u201cadded into\u201d to the seller\u2019s account.<\/p>\n\n\n\n
This is technically called the \u201cdouble spending problem<\/a>\u201d \u2013 how do you ensure that you\u2019re not spending the same money twice? Without someone to do this, you could spend money and at the same time continue to hold on to that money.<\/p>\n\n\n\n
So it\u2019s a big problem really \u2013 modern life requires that we rely on, trust in and pay for \u201ctrusted\u201d third party intermediaries to ensure that value (money) does actually digitally \u201cchange hands\u201d. That is why Visa and MasterCard exist, and why PayPal and others link with your bank accounts.<\/p>\n\n\n\n
How Blockchain works?<\/strong><\/h2>\n\n\n\n
It is essential to remember that the blockchain is a technology \u2013 mathematically complex software code to be specific. And Bitcoin (or Ethereum or any of the other cryptos on offer) are just applications of that technology.<\/p>\n\n\n\n
So the key principles are:<\/p>\n\n\n\n
\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\nIf 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\nHappy 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"};
\nThat\u2019s why you have governments having the final say on your identity, and votes need to be physically counted and recounted by hundreds of volunteers, and clerks in dingy offices maintain ledgers and certificates to confirm whether or not you own your farm\/white picket-fenced bungalow. <\/p>\n\n\n\n
That is why you need financial intermediaries to ensure that when you buy your CR7 Jersey, using a credit card, the money (value) is \u201cremoved\u201d from your account and \u201cadded into\u201d to the seller\u2019s account.<\/p>\n\n\n\n
This is technically called the \u201cdouble spending problem<\/a>\u201d \u2013 how do you ensure that you\u2019re not spending the same money twice? Without someone to do this, you could spend money and at the same time continue to hold on to that money.<\/p>\n\n\n\n
So it\u2019s a big problem really \u2013 modern life requires that we rely on, trust in and pay for \u201ctrusted\u201d third party intermediaries to ensure that value (money) does actually digitally \u201cchange hands\u201d. That is why Visa and MasterCard exist, and why PayPal and others link with your bank accounts.<\/p>\n\n\n\n
How Blockchain works?<\/strong><\/h2>\n\n\n\n
It is essential to remember that the blockchain is a technology \u2013 mathematically complex software code to be specific. And Bitcoin (or Ethereum or any of the other cryptos on offer) are just applications of that technology.<\/p>\n\n\n\n
So the key principles are:<\/p>\n\n\n\n
\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\nIf 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\nHappy 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"};
\nA \"chain of custody\" can sometimes also be called the \"provenance\" \u2013 they both mean the same thing: the sequence of historical events concerning the data in question.<\/p>\n\n\n\n
That\u2019s why you have governments having the final say on your identity, and votes need to be physically counted and recounted by hundreds of volunteers, and clerks in dingy offices maintain ledgers and certificates to confirm whether or not you own your farm\/white picket-fenced bungalow. <\/p>\n\n\n\n
That is why you need financial intermediaries to ensure that when you buy your CR7 Jersey, using a credit card, the money (value) is \u201cremoved\u201d from your account and \u201cadded into\u201d to the seller\u2019s account.<\/p>\n\n\n\n
This is technically called the \u201cdouble spending problem<\/a>\u201d \u2013 how do you ensure that you\u2019re not spending the same money twice? Without someone to do this, you could spend money and at the same time continue to hold on to that money.<\/p>\n\n\n\n
So it\u2019s a big problem really \u2013 modern life requires that we rely on, trust in and pay for \u201ctrusted\u201d third party intermediaries to ensure that value (money) does actually digitally \u201cchange hands\u201d. That is why Visa and MasterCard exist, and why PayPal and others link with your bank accounts.<\/p>\n\n\n\n
How Blockchain works?<\/strong><\/h2>\n\n\n\n
It is essential to remember that the blockchain is a technology \u2013 mathematically complex software code to be specific. And Bitcoin (or Ethereum or any of the other cryptos on offer) are just applications of that technology.<\/p>\n\n\n\n
So the key principles are:<\/p>\n\n\n\n
\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\nIf 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\nHappy 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"};
\nWhile that may work well for planet and continental surveys, it doesn\u2019t work so well in the digital world. or voting, banking, financial transactions, transferring land title, discharging contractual obligations etc. You need independent and \u201ctrusted third parties\u201d to verify a chain of events, and solemnly reassure you that the \"chain of custody\" was unbroken.<\/p>\n\n\n\n
A \"chain of custody\" can sometimes also be called the \"provenance\" \u2013 they both mean the same thing: the sequence of historical events concerning the data in question.<\/p>\n\n\n\n
That\u2019s why you have governments having the final say on your identity, and votes need to be physically counted and recounted by hundreds of volunteers, and clerks in dingy offices maintain ledgers and certificates to confirm whether or not you own your farm\/white picket-fenced bungalow. <\/p>\n\n\n\n
That is why you need financial intermediaries to ensure that when you buy your CR7 Jersey, using a credit card, the money (value) is \u201cremoved\u201d from your account and \u201cadded into\u201d to the seller\u2019s account.<\/p>\n\n\n\n
This is technically called the \u201cdouble spending problem<\/a>\u201d \u2013 how do you ensure that you\u2019re not spending the same money twice? Without someone to do this, you could spend money and at the same time continue to hold on to that money.<\/p>\n\n\n\n
So it\u2019s a big problem really \u2013 modern life requires that we rely on, trust in and pay for \u201ctrusted\u201d third party intermediaries to ensure that value (money) does actually digitally \u201cchange hands\u201d. That is why Visa and MasterCard exist, and why PayPal and others link with your bank accounts.<\/p>\n\n\n\n
How Blockchain works?<\/strong><\/h2>\n\n\n\n
It is essential to remember that the blockchain is a technology \u2013 mathematically complex software code to be specific. And Bitcoin (or Ethereum or any of the other cryptos on offer) are just applications of that technology.<\/p>\n\n\n\n
So the key principles are:<\/p>\n\n\n\n
\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\nIf 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\nHappy 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"};
\nYou then know that prior to that divergence. Both lists are in accord, so those signatures represent the minimum number of people who signed to support saving the planet.<\/p>\n\n\n\n
While that may work well for planet and continental surveys, it doesn\u2019t work so well in the digital world. or voting, banking, financial transactions, transferring land title, discharging contractual obligations etc. You need independent and \u201ctrusted third parties\u201d to verify a chain of events, and solemnly reassure you that the \"chain of custody\" was unbroken.<\/p>\n\n\n\n
A \"chain of custody\" can sometimes also be called the \"provenance\" \u2013 they both mean the same thing: the sequence of historical events concerning the data in question.<\/p>\n\n\n\n
That\u2019s why you have governments having the final say on your identity, and votes need to be physically counted and recounted by hundreds of volunteers, and clerks in dingy offices maintain ledgers and certificates to confirm whether or not you own your farm\/white picket-fenced bungalow. <\/p>\n\n\n\n
That is why you need financial intermediaries to ensure that when you buy your CR7 Jersey, using a credit card, the money (value) is \u201cremoved\u201d from your account and \u201cadded into\u201d to the seller\u2019s account.<\/p>\n\n\n\n
This is technically called the \u201cdouble spending problem<\/a>\u201d \u2013 how do you ensure that you\u2019re not spending the same money twice? Without someone to do this, you could spend money and at the same time continue to hold on to that money.<\/p>\n\n\n\n
So it\u2019s a big problem really \u2013 modern life requires that we rely on, trust in and pay for \u201ctrusted\u201d third party intermediaries to ensure that value (money) does actually digitally \u201cchange hands\u201d. That is why Visa and MasterCard exist, and why PayPal and others link with your bank accounts.<\/p>\n\n\n\n
How Blockchain works?<\/strong><\/h2>\n\n\n\n
It is essential to remember that the blockchain is a technology \u2013 mathematically complex software code to be specific. And Bitcoin (or Ethereum or any of the other cryptos on offer) are just applications of that technology.<\/p>\n\n\n\n
So the key principles are:<\/p>\n\n\n\n
\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\nIf 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\nHappy 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"};
\nYou would need to trace back your separate trails, one signature at a time, to locate the last<\/em> discrepancy. And then you'd have to work further back to identify the first result that diverged between your signature sheets. Prior to that root divergence, all other signatures on the two lists should match up.<\/p>\n\n\n\n
You then know that prior to that divergence. Both lists are in accord, so those signatures represent the minimum number of people who signed to support saving the planet.<\/p>\n\n\n\n
While that may work well for planet and continental surveys, it doesn\u2019t work so well in the digital world. or voting, banking, financial transactions, transferring land title, discharging contractual obligations etc. You need independent and \u201ctrusted third parties\u201d to verify a chain of events, and solemnly reassure you that the \"chain of custody\" was unbroken.<\/p>\n\n\n\n
A \"chain of custody\" can sometimes also be called the \"provenance\" \u2013 they both mean the same thing: the sequence of historical events concerning the data in question.<\/p>\n\n\n\n
That\u2019s why you have governments having the final say on your identity, and votes need to be physically counted and recounted by hundreds of volunteers, and clerks in dingy offices maintain ledgers and certificates to confirm whether or not you own your farm\/white picket-fenced bungalow. <\/p>\n\n\n\n
That is why you need financial intermediaries to ensure that when you buy your CR7 Jersey, using a credit card, the money (value) is \u201cremoved\u201d from your account and \u201cadded into\u201d to the seller\u2019s account.<\/p>\n\n\n\n
This is technically called the \u201cdouble spending problem<\/a>\u201d \u2013 how do you ensure that you\u2019re not spending the same money twice? Without someone to do this, you could spend money and at the same time continue to hold on to that money.<\/p>\n\n\n\n
So it\u2019s a big problem really \u2013 modern life requires that we rely on, trust in and pay for \u201ctrusted\u201d third party intermediaries to ensure that value (money) does actually digitally \u201cchange hands\u201d. That is why Visa and MasterCard exist, and why PayPal and others link with your bank accounts.<\/p>\n\n\n\n
How Blockchain works?<\/strong><\/h2>\n\n\n\n
It is essential to remember that the blockchain is a technology \u2013 mathematically complex software code to be specific. And Bitcoin (or Ethereum or any of the other cryptos on offer) are just applications of that technology.<\/p>\n\n\n\n
So the key principles are:<\/p>\n\n\n\n
\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\nIf 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\nHappy 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"};
\nLet's say you conduct it in an identical sequence across the same continent, but come up with different sets of signatures on the petition. Which version of the signed petition is the \u201csource of truth\u201d?<\/p>\n\n\n\n
You would need to trace back your separate trails, one signature at a time, to locate the last<\/em> discrepancy. And then you'd have to work further back to identify the first result that diverged between your signature sheets. Prior to that root divergence, all other signatures on the two lists should match up.<\/p>\n\n\n\n
You then know that prior to that divergence. Both lists are in accord, so those signatures represent the minimum number of people who signed to support saving the planet.<\/p>\n\n\n\n
While that may work well for planet and continental surveys, it doesn\u2019t work so well in the digital world. or voting, banking, financial transactions, transferring land title, discharging contractual obligations etc. You need independent and \u201ctrusted third parties\u201d to verify a chain of events, and solemnly reassure you that the \"chain of custody\" was unbroken.<\/p>\n\n\n\n
A \"chain of custody\" can sometimes also be called the \"provenance\" \u2013 they both mean the same thing: the sequence of historical events concerning the data in question.<\/p>\n\n\n\n
That\u2019s why you have governments having the final say on your identity, and votes need to be physically counted and recounted by hundreds of volunteers, and clerks in dingy offices maintain ledgers and certificates to confirm whether or not you own your farm\/white picket-fenced bungalow. <\/p>\n\n\n\n
That is why you need financial intermediaries to ensure that when you buy your CR7 Jersey, using a credit card, the money (value) is \u201cremoved\u201d from your account and \u201cadded into\u201d to the seller\u2019s account.<\/p>\n\n\n\n
This is technically called the \u201cdouble spending problem<\/a>\u201d \u2013 how do you ensure that you\u2019re not spending the same money twice? Without someone to do this, you could spend money and at the same time continue to hold on to that money.<\/p>\n\n\n\n
So it\u2019s a big problem really \u2013 modern life requires that we rely on, trust in and pay for \u201ctrusted\u201d third party intermediaries to ensure that value (money) does actually digitally \u201cchange hands\u201d. That is why Visa and MasterCard exist, and why PayPal and others link with your bank accounts.<\/p>\n\n\n\n
How Blockchain works?<\/strong><\/h2>\n\n\n\n
It is essential to remember that the blockchain is a technology \u2013 mathematically complex software code to be specific. And Bitcoin (or Ethereum or any of the other cryptos on offer) are just applications of that technology.<\/p>\n\n\n\n
So the key principles are:<\/p>\n\n\n\n
\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\nIf 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\nHappy 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"};
\nWhat happens if you and your friend independently and separately<\/em> conduct the same petition campaign? Let\u2019s say it\u2019s for the \u201csave the planet\u201d cause.<\/p>\n\n\n\n
Let's say you conduct it in an identical sequence across the same continent, but come up with different sets of signatures on the petition. Which version of the signed petition is the \u201csource of truth\u201d?<\/p>\n\n\n\n
You would need to trace back your separate trails, one signature at a time, to locate the last<\/em> discrepancy. And then you'd have to work further back to identify the first result that diverged between your signature sheets. Prior to that root divergence, all other signatures on the two lists should match up.<\/p>\n\n\n\n
You then know that prior to that divergence. Both lists are in accord, so those signatures represent the minimum number of people who signed to support saving the planet.<\/p>\n\n\n\n
While that may work well for planet and continental surveys, it doesn\u2019t work so well in the digital world. or voting, banking, financial transactions, transferring land title, discharging contractual obligations etc. You need independent and \u201ctrusted third parties\u201d to verify a chain of events, and solemnly reassure you that the \"chain of custody\" was unbroken.<\/p>\n\n\n\n
A \"chain of custody\" can sometimes also be called the \"provenance\" \u2013 they both mean the same thing: the sequence of historical events concerning the data in question.<\/p>\n\n\n\n
That\u2019s why you have governments having the final say on your identity, and votes need to be physically counted and recounted by hundreds of volunteers, and clerks in dingy offices maintain ledgers and certificates to confirm whether or not you own your farm\/white picket-fenced bungalow. <\/p>\n\n\n\n
That is why you need financial intermediaries to ensure that when you buy your CR7 Jersey, using a credit card, the money (value) is \u201cremoved\u201d from your account and \u201cadded into\u201d to the seller\u2019s account.<\/p>\n\n\n\n
This is technically called the \u201cdouble spending problem<\/a>\u201d \u2013 how do you ensure that you\u2019re not spending the same money twice? Without someone to do this, you could spend money and at the same time continue to hold on to that money.<\/p>\n\n\n\n
So it\u2019s a big problem really \u2013 modern life requires that we rely on, trust in and pay for \u201ctrusted\u201d third party intermediaries to ensure that value (money) does actually digitally \u201cchange hands\u201d. That is why Visa and MasterCard exist, and why PayPal and others link with your bank accounts.<\/p>\n\n\n\n
How Blockchain works?<\/strong><\/h2>\n\n\n\n
It is essential to remember that the blockchain is a technology \u2013 mathematically complex software code to be specific. And Bitcoin (or Ethereum or any of the other cryptos on offer) are just applications of that technology.<\/p>\n\n\n\n
So the key principles are:<\/p>\n\n\n\n
\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\nIf 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\nHappy 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"};
\nWhy use blockchain?<\/strong><\/h2>\n\n\n\n
What happens if you and your friend independently and separately<\/em> conduct the same petition campaign? Let\u2019s say it\u2019s for the \u201csave the planet\u201d cause.<\/p>\n\n\n\n
Let's say you conduct it in an identical sequence across the same continent, but come up with different sets of signatures on the petition. Which version of the signed petition is the \u201csource of truth\u201d?<\/p>\n\n\n\n
You would need to trace back your separate trails, one signature at a time, to locate the last<\/em> discrepancy. And then you'd have to work further back to identify the first result that diverged between your signature sheets. Prior to that root divergence, all other signatures on the two lists should match up.<\/p>\n\n\n\n
You then know that prior to that divergence. Both lists are in accord, so those signatures represent the minimum number of people who signed to support saving the planet.<\/p>\n\n\n\n
While that may work well for planet and continental surveys, it doesn\u2019t work so well in the digital world. or voting, banking, financial transactions, transferring land title, discharging contractual obligations etc. You need independent and \u201ctrusted third parties\u201d to verify a chain of events, and solemnly reassure you that the \"chain of custody\" was unbroken.<\/p>\n\n\n\n
A \"chain of custody\" can sometimes also be called the \"provenance\" \u2013 they both mean the same thing: the sequence of historical events concerning the data in question.<\/p>\n\n\n\n
That\u2019s why you have governments having the final say on your identity, and votes need to be physically counted and recounted by hundreds of volunteers, and clerks in dingy offices maintain ledgers and certificates to confirm whether or not you own your farm\/white picket-fenced bungalow. <\/p>\n\n\n\n
That is why you need financial intermediaries to ensure that when you buy your CR7 Jersey, using a credit card, the money (value) is \u201cremoved\u201d from your account and \u201cadded into\u201d to the seller\u2019s account.<\/p>\n\n\n\n
This is technically called the \u201cdouble spending problem<\/a>\u201d \u2013 how do you ensure that you\u2019re not spending the same money twice? Without someone to do this, you could spend money and at the same time continue to hold on to that money.<\/p>\n\n\n\n
So it\u2019s a big problem really \u2013 modern life requires that we rely on, trust in and pay for \u201ctrusted\u201d third party intermediaries to ensure that value (money) does actually digitally \u201cchange hands\u201d. That is why Visa and MasterCard exist, and why PayPal and others link with your bank accounts.<\/p>\n\n\n\n
How Blockchain works?<\/strong><\/h2>\n\n\n\n
It is essential to remember that the blockchain is a technology \u2013 mathematically complex software code to be specific. And Bitcoin (or Ethereum or any of the other cryptos on offer) are just applications of that technology.<\/p>\n\n\n\n
So the key principles are:<\/p>\n\n\n\n
\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\nIf 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\nHappy 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"};
\nConsensus Based is an approach to decision making. It is a creative and dynamic way of reaching agreement between all members of a group. A transaction on Blockchain can be executed only if all the parties on the network unanimously approve it. It is however, subjected to alterations to suit various circumstances.<\/p>\n\n\n\n
Why use blockchain?<\/strong><\/h2>\n\n\n\n
What happens if you and your friend independently and separately<\/em> conduct the same petition campaign? Let\u2019s say it\u2019s for the \u201csave the planet\u201d cause.<\/p>\n\n\n\n
Let's say you conduct it in an identical sequence across the same continent, but come up with different sets of signatures on the petition. Which version of the signed petition is the \u201csource of truth\u201d?<\/p>\n\n\n\n
You would need to trace back your separate trails, one signature at a time, to locate the last<\/em> discrepancy. And then you'd have to work further back to identify the first result that diverged between your signature sheets. Prior to that root divergence, all other signatures on the two lists should match up.<\/p>\n\n\n\n
You then know that prior to that divergence. Both lists are in accord, so those signatures represent the minimum number of people who signed to support saving the planet.<\/p>\n\n\n\n
While that may work well for planet and continental surveys, it doesn\u2019t work so well in the digital world. or voting, banking, financial transactions, transferring land title, discharging contractual obligations etc. You need independent and \u201ctrusted third parties\u201d to verify a chain of events, and solemnly reassure you that the \"chain of custody\" was unbroken.<\/p>\n\n\n\n
A \"chain of custody\" can sometimes also be called the \"provenance\" \u2013 they both mean the same thing: the sequence of historical events concerning the data in question.<\/p>\n\n\n\n
That\u2019s why you have governments having the final say on your identity, and votes need to be physically counted and recounted by hundreds of volunteers, and clerks in dingy offices maintain ledgers and certificates to confirm whether or not you own your farm\/white picket-fenced bungalow. <\/p>\n\n\n\n
That is why you need financial intermediaries to ensure that when you buy your CR7 Jersey, using a credit card, the money (value) is \u201cremoved\u201d from your account and \u201cadded into\u201d to the seller\u2019s account.<\/p>\n\n\n\n
This is technically called the \u201cdouble spending problem<\/a>\u201d \u2013 how do you ensure that you\u2019re not spending the same money twice? Without someone to do this, you could spend money and at the same time continue to hold on to that money.<\/p>\n\n\n\n
So it\u2019s a big problem really \u2013 modern life requires that we rely on, trust in and pay for \u201ctrusted\u201d third party intermediaries to ensure that value (money) does actually digitally \u201cchange hands\u201d. That is why Visa and MasterCard exist, and why PayPal and others link with your bank accounts.<\/p>\n\n\n\n
How Blockchain works?<\/strong><\/h2>\n\n\n\n
It is essential to remember that the blockchain is a technology \u2013 mathematically complex software code to be specific. And Bitcoin (or Ethereum or any of the other cryptos on offer) are just applications of that technology.<\/p>\n\n\n\n
So the key principles are:<\/p>\n\n\n\n
\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\nIf 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\nHappy 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"};
\n6. Consensus Based<\/strong><\/h2>\n\n\n\n
Consensus Based is an approach to decision making. It is a creative and dynamic way of reaching agreement between all members of a group. A transaction on Blockchain can be executed only if all the parties on the network unanimously approve it. It is however, subjected to alterations to suit various circumstances.<\/p>\n\n\n\n
Why use blockchain?<\/strong><\/h2>\n\n\n\n
What happens if you and your friend independently and separately<\/em> conduct the same petition campaign? Let\u2019s say it\u2019s for the \u201csave the planet\u201d cause.<\/p>\n\n\n\n
Let's say you conduct it in an identical sequence across the same continent, but come up with different sets of signatures on the petition. Which version of the signed petition is the \u201csource of truth\u201d?<\/p>\n\n\n\n
You would need to trace back your separate trails, one signature at a time, to locate the last<\/em> discrepancy. And then you'd have to work further back to identify the first result that diverged between your signature sheets. Prior to that root divergence, all other signatures on the two lists should match up.<\/p>\n\n\n\n
You then know that prior to that divergence. Both lists are in accord, so those signatures represent the minimum number of people who signed to support saving the planet.<\/p>\n\n\n\n
While that may work well for planet and continental surveys, it doesn\u2019t work so well in the digital world. or voting, banking, financial transactions, transferring land title, discharging contractual obligations etc. You need independent and \u201ctrusted third parties\u201d to verify a chain of events, and solemnly reassure you that the \"chain of custody\" was unbroken.<\/p>\n\n\n\n
A \"chain of custody\" can sometimes also be called the \"provenance\" \u2013 they both mean the same thing: the sequence of historical events concerning the data in question.<\/p>\n\n\n\n
That\u2019s why you have governments having the final say on your identity, and votes need to be physically counted and recounted by hundreds of volunteers, and clerks in dingy offices maintain ledgers and certificates to confirm whether or not you own your farm\/white picket-fenced bungalow. <\/p>\n\n\n\n
That is why you need financial intermediaries to ensure that when you buy your CR7 Jersey, using a credit card, the money (value) is \u201cremoved\u201d from your account and \u201cadded into\u201d to the seller\u2019s account.<\/p>\n\n\n\n