So I’m working with this code for a blockchain mining class
const Block = require('./Block');
class Blockchain{
constructor(){
this.chain = [Blockchain.genesis()];
}
addBlock({data}){
const newBlock = Block.mineBlock([
lastBlock: this.chain[this.chain.length-1],
data
]);
this.chain.push();
}
}
module.exports = Blockchain;
And I keep getting this error Unexpected token, expected , (8:21), for this line:
lastBlock: this.chain[this.chain.length-1],
Any help will be appreciated!
Advertisement
Answer
Try Using this
Block.mineBlock({
lastBlock: this.chain[this.chain.length-1],
data
})
Seems to me like you key:value pairs are not properly formatted..
The code in probably taking
lastBlock: this.chain[this.chain.length-1],
this above line as Key and is expecting a value from data