-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
23 lines (18 loc) · 850 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import Blockchain from "./Models/Blockchain";
import Block from "./Models/Block";
// Create a new Blockchain
let GCoin = new Blockchain();
// add some transactions to the blockchain
GCoin.addBlock(new Block({ amount : 10 }));
GCoin.addBlock(new Block({ amount : 10 }));
// printout the blockchain before manipulate the data.
console.log('________________VALID-BLOCKCHAIN________________');
console.log(JSON.stringify(GCoin.chain, null, 4));
console.log("Is Valid:", GCoin.validateChain());
// Try to manipulate the block chain data
GCoin.chain[1].data = { amount : 1000};
GCoin.chain[1].hash = GCoin.chain[1].calcHash();
// printout the blockchain after manipulate the data.
console.log('________________MANIPULATED-BLOCKCHAIN________________');
console.log(JSON.stringify(GCoin.chain, null, 4));
console.log("Is Valid:", GCoin.validateChain());