-
Notifications
You must be signed in to change notification settings - Fork 3
/
client.js
48 lines (43 loc) · 1.11 KB
/
client.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
43
44
45
46
47
48
const superagent = require('superagent');
//创建交易
superagent
.get('http://127.0.0.1:3000/blocks').end(function (err, res) {
console.log(res.text)
});
superagent
.get('http://127.0.0.1:3000/transactions').end(function (err, res) {
console.log(res.text)
});
//创建交易
superagent
.post('http://127.0.0.1:3000/transactions')
.query({
sendAddr: 'nezha',
recAddr: 'taizi',
value: 3
}).end((err, res) => {
// Calling the end function will send the request
});
superagent
.post('http://127.0.0.1:3000/transactions')
.query({
sendAddr: 'longwang',
recAddr: 'taizi',
value: 4
}).set('accept', 'json')
.end((err, res) => {
// Calling the end function will send the request
});
superagent
.get('http://127.0.0.1:3000/transactions').end(function (err, res) {
console.log(res.text)
});
// 挖矿
superagent.get('http://127.0.0.1:3000/mine').end(function (err, res) {
// 抛错拦截
if (err) {
console.log(err);
}
// 等待 code
console.log(res.text)
});