forked from huaigu/reth_miner
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmint_rbnb.js
100 lines (86 loc) · 2.64 KB
/
mint_rbnb.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const dotenv = require("dotenv");
dotenv.config();
const { ethers } = require("ethers");
const privateKey = process.env.PRIVATEKEY;
const wallet = new ethers.Wallet(privateKey);
const account = wallet.address;
const currentChallenge = ethers.utils.formatBytes32String("rBNB"); //0x72424e4200000000000000000000000000000000000000000000000000000000
const difficulty = "0x9999";
const tick = "rBNB";
const FgGreen = "\x1b[32m";
const FgYellow = "\x1b[33m";
const FgRed = "\x1b[31m";
const postResultData = async (body) => {
const res = await fetch(
"https://ec2-18-217-135-255.us-east-2.compute.amazonaws.com/validate",
{
headers: {
accept: "application/json, text/plain, */*",
"accept-language": "zh-CN,zh;q=0.9",
"content-type": "application/json",
"sec-ch-ua":
'"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "cross-site",
Referer: "https://bnb.reth.cc/",
"Referrer-Policy": "strict-origin-when-cross-origin",
},
body,
method: "POST",
}
);
const r = await res.json();
return r;
};
const getRandomInt = (min, max) => {
return Math.floor(Math.random() * (max - min + 1)) + min;
};
async function sleepMS(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
function findSolution(difficulty) {
while (1) {
const random_value = ethers.utils.randomBytes(32);
const potential_solution = ethers.utils.hexlify(random_value);
const hashed_solution = ethers.utils.keccak256(
ethers.utils.defaultAbiCoder.encode(
["bytes32", "bytes32", "address"],
[potential_solution, currentChallenge, account]
)
);
if (hashed_solution.startsWith(difficulty)) {
return potential_solution;
}
}
}
async function sendTransaction(solution) {
const body = {
solution,
challenge: currentChallenge,
address: account,
difficulty,
tick,
};
console.log(body);
await postResultData(JSON.stringify(body));
}
async function main() {
try {
while (true) {
const solution = findSolution(difficulty);
await sendTransaction(solution);
console.log(`发送成功 solution: ${solution}`);
await sleepMS(50);
}
} catch (err) {
console.log("错误 ------------------");
console.log(err);
console.log("-----------------------");
console.log("重启程序");
main();
}
}
main();