Last active
September 9, 2021 14:52
-
-
Save alexpanasUCLA/e0a2833ec5917847b304c86b8bfed12a to your computer and use it in GitHub Desktop.
Block Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SHA256 = require('crypto-js/sha256'); | |
class Block { | |
constructor(data){ | |
this.hash = "", | |
this.height = 0, | |
this.body = data, | |
this.time = 0, | |
this.previousBlockHash = "" | |
} | |
static genesisBlock() { | |
let genesisBlock = new this("First block in the chain - Genesis block"); | |
genesisBlock.hash = SHA256(JSON.stringify(genesisBlock)).toString(); | |
return genesisBlock; | |
} | |
} | |
module.exports = Block; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment