MXEN批量claim

calim

mint了一些polygon链上的xen,两个很简单的脚本代码

两份代码合起来

import { ethers } from "hardhat";
import * as fs from 'fs';
import * as path from 'path';

const pathText = path.resolve(__dirname,'./文本','./MXEN私钥及地址.txt')
//创建写入流
const ws = fs.createWriteStream(pathText);
const amount:number = 10;

async function main(){
    for(let i:number=0;i<amount;i++){
        let wallet = ethers.Wallet.createRandom();
        //ws.write(`${wallet.address}\n`);
        ws.write(`${wallet._signingKey().privateKey}\n`);
    }
}
main();
//关闭通道,可选可不选
//ws.close();


import { ethers } from "hardhat";

import * as fs from 'fs';
import * as path from 'path';
import { Wallet } from "ethers";

const owner:string = '';

const pathText = path.resolve(__dirname,'文本','MXEN私钥及地址.txt')
let read = fs.readFileSync(pathText,'utf-8');
//将文本里所有的私钥转换为钱包类型的数组
//一串私钥的长度
let wallets:Wallet[] = [];
let num:number = 0;
for(let i:number=0;i<10;i++){
    wallets[i] = new ethers.Wallet(read.slice(0+num,66+num));
    num += 67;
    //console.log(wallets[i]);
}

async function airdrioETH(){
    for(let i:number=0;i<wallets.length;i++){
        const tx = {
            to:wallets[i].address,
            amount:ethers.utils.parseEther('0.04')
        }
        //wallets[0].sendTransaction(tx);
    }
}

async function main(){
    console.log('批量mint中...');
    const provider = ethers.provider;
    const addressMXEN = '0x2AB0e9e4eE70FFf1fB9D67031E44F6410170d00e';
    const abiMXEN = [
        'function claimRank(uint256 term) external',
        'function claimMintReward() external',
        'function balanceOf(address account) external view returns (uint256)',
        'function approve(address spender, uint256 amount) external returns (bool)',
        'function transferFrom(address from,address to,uint256 amount) external returns (bool)'
    ]
    const contractMXEX = new ethers.Contract(addressMXEN,abiMXEN,provider);
    for(let i:number=0;i<wallets.length;i++){
        //await contractMXEX.connect(wallets[i]).claimRank(15);
        console.log(`第${i+1}个钱包有:${ethers.utils.formatEther(await contractMXEX.balanceOf(wallets[i].address))} MXEN`);
    }
}
main();