-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mine.js
42 lines (35 loc) · 860 Bytes
/
Mine.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const { Wallet, Block, Transaction } = require("./filesTerm");
const User1 = Wallet.create();
const User2 = Wallet.create();
const blockchain = [];
console.log("----Mining In progress----");
blockchain.push(
new Block({
parentHash: null,
stateHash: null,
miner: User1.publicKey,
transactions: [],
}).mine()
);
console.log(blockchain[0].hash());
blockchain.push(
new Block({
parentHash: blockchain[blockchain.length - 1].hash(),
stateHash: null,
miner: User1.publicKey,
transactions: [
new Transaction({
from: User1.publicKey,
to: User2.publicKey,
value: 15,
nonce: 0,
}).sign(User1.privateKey),
],
}).mine()
);
console.log(blockchain[1].hash());
console.log(
`%c
-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶`,
`font-family: monospace`
);