Logo

MBA534-Session 4 June 3, 2021 - Shared screen with speaker view
Emmanuella Ben-Eboh
25:21
it’s the MyChain folder
Emmanuella Ben-Eboh
25:24
directory
Faisal Alshehri
44:11
const SHA256 = require("crypto-js/sha256");class Block {constructor(data, previousHash) {this.data = data;this.timestamp = Date.now();this.previousHash = previousHash;this.hash = this.getHash();}getHash() {return SHA256(this.previousHash + this.timestamp +JSON.stringify(this.data)).toString();}}class Blockchain {constructor() {this.blockchain = [new Block("Genesis Block", '')];}getLastBlock() {return this.blockchain[this.blockchain.length-1];}createBlock(data) {this.blockchain.push(new Block(data, this.getLastBlock().hash));}isBlockchainValid() {for (let i=1; i<this.blockchain.length; i++) {let currentBlock = this.blockchain[i];let previousBlock = this.blockchain[i-1];if ((currentBlock.previousHash !== previousBlock.hash) ||(currentBlock.hash !== currentBlock.getHash())) {return false;}}return true;}}myChain = new Blockchain();console.log('\n-----\nNew blockchain created');console.log(myChain);myChain.createBlock("first set of transaction dat
Roxanne Hoffman
47:49
Add “console.log(myChain);” to print the log
Faisal Alshehri
01:00:16
return console.log(currentBlock.previousHash);
Nikhi Youssef
01:41:32
keep going
Haider Haseeb
01:41:41
I can keep going
Emmanuella Ben-Eboh
01:42:15
i need a little break though
joseph adamik
02:15:09
amazon
Samantha Deleon
02:18:26
@Joseph, agreed with Amazon. I also keep thinking about the Chipotle incident where the food was tainted and how they were able to figure out who in the supply chain messed up and shipped tainted food.
Samantha Deleon
02:44:13
Thank you!
Samantha Deleon
02:44:22
Good night everyone
Sze-Chieh Sophie Chen
02:44:22
Thank you!
Mohammad Saami
02:44:23
Thank you!
Parker Joyner
02:44:26
Thanks!