-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
150 lines (127 loc) · 4.7 KB
/
index.html
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ethers/6.9.2/ethers.umd.min.js"
integrity="sha512-sLFpRsIQP1UEi2fOI8XClBiucfQ3OxACkCQc4SQyDmpJwCzjyFwlTYQYsCPJIakPxGvAvG8rjzmunxsAhw3RUw=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head>
<body>
<h1>INSCRIBE BOT</h1>
<label for="privateKey">Private Key</label>
<input type="text" id="privateKey" placeholder="Private Key" value="" style="width: 100%; height: 50px; font-size: 20px; padding: 10px; margin-bottom: 10px;">
<label for="numberOfMints">How many mints?</label>
<input type="number" id="numberOfMints" placeholder="Number of Mints" value="100" style="width: 100%; height: 50px; font-size: 20px; padding: 10px; margin-bottom: 10px;">
<button onclick="runMultipleMints()" style="width: 100%; height: 50px; font-size: 20px; padding: 10px; margin-bottom: 10px;">Run</button>
<button onclick="runForever()" style="width: 100%; height: 50px; font-size: 20px; padding: 10px; margin-bottom: 10px;">Run Forever</button>
<br />
<section id="status"></section>
<script>
const { ethers } = window;
const { JsonRpcProvider, Wallet, Contract } = ethers;
const contractABI = [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "string",
"name": "data",
"type": "string"
}
],
"name": "Inscribe",
"type": "event"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "inscribe",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
];
const provider = new JsonRpcProvider(
"https://api.evm.eosnetwork.com/",
undefined,
{
batchMaxCount: 1,
}
);
const contractAddress = "0xC10A988680355BdFfE0B998Cd12098264C3957Bd";
let wallet;
let contract;
const consoleAsStatus = (...args) => {
const status = document.getElementById("status");
status.innerHTML += args.join(" ") + "<br />";
console.log(...args);
};
async function mint() {
let transaction = await contract.inscribe(
"0x7b2270223a22656f732d3230222c226f70223a226d696e74222c227469636b223a226563686f222c22616d74223a2231303030227d"
);
consoleAsStatus(`Transaction Hash: <a href="https://explorer.evm.eosnetwork.com/tx/${transaction.hash}" target="_blank">${transaction.hash}</a>`);
const receipt = await Promise.race([
transaction.wait(1),
new Promise(r => setTimeout(r, 5000))
]);
if(receipt) consoleAsStatus(`Transaction was mined in block ${receipt.blockNumber}`);
}
const setupWallet = () => {
if(!wallet){
wallet = new Wallet(document.getElementById("privateKey").value, provider);
contract = new Contract(contractAddress, contractABI, wallet);
}
}
async function runMultipleMints() {
try {
setupWallet();
const numberOfMints = parseInt(document.getElementById('numberOfMints').value);
if(isNaN(numberOfMints) || !numberOfMints) {
alert('Please enter a valid number of mints');
return;
}
const startTime = new Date();
for (let i = 0; i < numberOfMints; i++) {
consoleAsStatus(`Minting ${i + 1}/${numberOfMints}`);
await mint().catch(consoleAsStatus);
}
const endTime = new Date();
const duration = (endTime - startTime) / 1000; // Convert milliseconds to seconds
consoleAsStatus(`Finished minting Smart Inscriptions in ${duration} seconds.`);
} catch (e) {
consoleAsStatus(e);
}
}
async function runForever() {
try {
setupWallet();
while(true) {
await mint().catch(consoleAsStatus);
}
} catch (e) {
consoleAsStatus(e);
}
}
</script>
</body>
</html>