最近区块链很火,有没有js版本区块链技术的实现,想学习下
网友回复
这样才正确,楼主的代码有误
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <title>BFW DEMO JS PAGE</title> <script id="bfwone" data="dep=jquery.17|crypto-js-3.1.9-1/crypto-js" src="//repo.bfw.wiki/bfwrepo/js/bfwone.js"></script> <script> class Block { constructor(index, timestamp, data, previousHash = '') { this.index = index; this.previousHash = previousHash; this.timestamp = timestamp; this.data = data; this.hash = this.calculateHash(); } calculateHash() { return CryptoJS.SHA256(this.index + this.previousHash + this.timestamp + JSON.stringify(this.data)).toString(); } } class Blockchain { constructor() { this....
点击查看剩余70%
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <title>BFW DEMO JS PAGE</title> <script id="bfwone" data="dep=jquery.17|crypto-js-3.1.9-1/crypto-js" src="http://repo.bfw.wiki/bfwrepo/js/bfwone.js"></script> <script> class Block { constructor(index, timestamp, data, previousHash = '') { this.index = index; this.previousHash = previousHash; this.timestamp = timestamp; this.data = data; this.hash = this.calculateHash(); } calculateHash() { return CryptoJS.SHA256(this.index + this.previousHash + this.timestamp + JSON.stringify(this.data)).toString(); } } class Blockchain { constructor() { this.chain = [this.createGenesisBlock()]; } createGenesisBlock() { ...
点击查看剩余70%