forked from chenlongzhen/EvmosTestnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EvmosiansNft.js
74 lines (67 loc) · 2.68 KB
/
EvmosiansNft.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
const ethers = require('ethers')
require("dotenv").config();
const provider = new ethers.providers.JsonRpcProvider(`https://evmos-evm-rpc.tk/`);
const abi = require('./ABI/Evmosian.json')
const fs = require('fs');
start();
async function start() {
for (let i = 0; i <= 1000; i++) {
const account = ethers.Wallet.createRandom();
let faucetWallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
let wallet = new ethers.Wallet(account.privateKey, provider);
console.log("ADDRESS: " + wallet.address);
console.log("PRIVATE KEY: " + wallet.privateKey);
await transferToMint(wallet, faucetWallet)
// console.log("Minting Evmosian NFT");
// await mintEvmosiansNFT(wallet, '0x7ed7D20698931c98Ecc8F4Fe95eE7CEBe35b6548');
console.log("Minting Validator NFT");
await mintEvmosiansNFT(wallet, '0xF12Aa72B237C1B936f5917BF0f90c1D8b7D29a1D');
console.log("Minting Builder NFT");
await mintEvmosiansNFT(wallet, '0x53a6ab26100898915e500661c603082c065d1e77');
console.log("Minting Educator NFT");
await mintEvmosiansNFT(wallet, '0xaD4c0fF6A3D20a9d420D8DBeF1b5F8E9f907a663');
}
}
function writeOutput(data) {
fs.appendFile('keys.txt', data, function (err) {
if (err) throw err;
});
}
async function transferToMint(wallet, faucetWallet) {
return new Promise(async (resolve, reject) => {
console.log('Transferring PHOTON to ' + wallet.address);
let tx = {
to: wallet.address,
value: ethers.utils.parseEther(process.env.TRANSFER_AMOUNT)
}
faucetWallet.sendTransaction(tx).then(async (txObj) => {
await txObj.wait();
console.log("PHOTON sent!");
resolve(true)
}).catch(err => {
console.log(err)
reject(err);
});
});
}
async function mintEvmosiansNFT(wallet, contract) {
return new Promise(async (resolve, reject) => {
const evmosiansManifested = new ethers.Contract(contract, abi, provider);
let evmosiansManifestedConnected = evmosiansManifested.connect(wallet);
let nonce = await provider.getTransactionCount(wallet.address);
let gasPrice = (await provider.getGasPrice());
evmosiansManifestedConnected.mint({
gasLimit: 200000,
gasPrice: gasPrice,
nonce
}).then(async (result) => {
let res = await result.wait();
console.log("NFT Minted!");
writeOutput(`${wallet.address}:${wallet.privateKey}:${res.transactionHash}\n`);
resolve(true);
}).catch(err => {
console.log(err)
reject(err);
});
});
}