Olá ! , estou aprendendo a programar uma mini blockchain mas já travei aqui em algum erro de sintaxe, como sou iniciante talvez seja uma bobeira mas não consegui entender aonde , se alguem puder dar uma dica agradeço segue o codigo
const SHA256 = require('crypto-js/sha256');
class Block {
constructor(index, timestamp, data, previousHash = ''){
this.index = index;
this.timestamp = timestamp;
this.data = data;
this.previousHash = previousHash;
this.hash = this.calculateHash();
}
calculateHash(){
return SHA256(this.index + this.previousHash + this.timestamp + JSON.stringify(this.data)).toString();
}
}
class Blockchain {
constructor(){
this.chain = [this.createGenesisBlock()];
}
createGenesisBlock(){
return new Block(0,'17/02/1999', 'Genesis Block',0);
}
getLatestBlock(){
return this.chain[this.chain.length -1];
}
addNewBlock(newBlock){
newBlock.previousHash = this.getLatestBlock.hash;
newBlock.hash = newBlock.calculateHash();
this.chain.push(newBlock);
}
}
let aitak = new Blockchain();
aitak.addNewBlock(new Block(1, '12/01/2000', {amount : 50 }));
aitak.addNewBlock(new Block(2, '15/03/2000', {amount : 520 }));
console.log(JSON.stringify(aitak, null, 4));
Agora, isso que dá, quando vou rodar no terminal -->
class Block {
^^^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:134:18)
at node.js:961:3