first commit

This commit is contained in:
jack
2025-11-12 16:47:21 +08:00
commit 266ba871a4
43 changed files with 3747 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
0x618a59dcbbc05a38e10b9872f50855c1b52dd01baced785a7134876ba404be1b
View File
View File
+56
View File
@@ -0,0 +1,56 @@
import { ethers } from 'ethers';
const providerUrl = 'https://testnet-rpc.monad.xyz';
const provider = new ethers.JsonRpcProvider(providerUrl);
const privateKeyList = [
'0x3991542110242368f4770716be904b0ca6d44a8dbe4501771833b1a3642198d1'
];
const stakingContractAddress = '0xcBE623D259261FFa0CFAff44484bFF46c1b7D6c2';
// Function to generate random delay between 5-10 seconds
const getRandomDelay = () => {
return Math.floor(Math.random() * (10000 - 5000 + 1)) + 5000;
};
// Function to handle staking for a single wallet
async function stakeMon(wallet) {
try {
const balance = await provider.getBalance(wallet.address);
console.log(`Wallet ${wallet.address} balance:`, ethers.formatEther(balance));
// 签到合约, 金额设置 0
const amountToStake = ethers.parseEther('0');
if (balance < amountToStake) {
throw new Error(`Insufficient balance for staking in wallet ${wallet.address}`);
}
const tx = await wallet.sendTransaction({
to: stakingContractAddress,
value: amountToStake,
data: '0x7ab71841',
gasLimit: 1000000,
gasPrice: ethers.parseUnits('52', 'gwei')
});
console.log(`Stake transaction hash for ${wallet.address}:`, tx.hash);
const receipt = await tx.wait();
console.log(`Stake transaction receipt for ${wallet.address}:`, receipt);
} catch (error) {
console.error(`Error staking $MON for ${wallet.address}:`, error);
}
}
// Function to process all wallets with delay
async function processAllWallets() {
for (const privateKey of privateKeyList) {
const wallet = new ethers.Wallet(privateKey, provider);
await stakeMon(wallet);
// Add random delay between 5-10 seconds, except for the last wallet
if (privateKey !== privateKeyList[privateKeyList.length - 1]) {
const delay = getRandomDelay();
console.log(`Waiting ${delay/1000} seconds before next wallet...`);
await new Promise(resolve => setTimeout(resolve, delay));
}
}
}
processAllWallets();
+148
View File
@@ -0,0 +1,148 @@
import {ethers} from "ethers";
import fs from 'fs/promises';
import path from 'path';
import { fileURLToPath } from 'url';
// Monad 测试网 RPC URL
const providerUrl = "https://testnet-rpc.monad.xyz";
const provider = new ethers.JsonRpcProvider(providerUrl);
// 合约地址、合约方法哈希值及描述
const contractData = [
{
address: "0x2c9c959516e9aaedb2c748224a41249202ca8be7",
dataHash: "0xd5575982",
description: "Magmastaking"
},
{
address: "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701",
dataHash: "0xd5575982",
description: "ApeBond"
},
{
address: "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701",
dataHash: "0xd0e30db0",
description: "OctoSwap - WMON"
}
];
// 读取私钥文件
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const filePath = path.join(__dirname, './AccountList.txt');
function sleep(min_delay, max_delay) {
// 随机睡眠
const delay = Math.floor(Math.random() * (max_delay * 1000 - min_delay * 1000 + 1)) + min_delay * 1000;
return new Promise((resolve) => setTimeout(resolve, delay));
}
function getRandomAmount() {
// 生成随机交易金额 0.00000000****(最后4位随机数)
const randomTail = Math.floor(1000 + Math.random() * 2000); // 生成1000-9999的随机4位数
return ethers.parseEther(`0.00000000${randomTail}`);
}
function getRandomContractData() {
// 随机获取合约地址、合约方法哈希值及描述
if (contractData.length === 0) {
console.error("The contract data array is empty, the contract cannot be selected, and the program exits.");
process.exit(1);
}
const randomIndex = Math.floor(Math.random() * contractData.length);
return contractData[randomIndex];
}
function checkWalletBalance(balance) {
if (balance <= ethers.parseEther("5")) {
console.error("The wallet balance is invalid.");
process.exit(1);
}
}
async function executeContract(wallet) {
try {
// 随机选择一个合约地址、合约方法哈希值及描述
const {address, dataHash, description} = getRandomContractData();
console.log(`Selected contract: ${description}`);
console.log("Selected contract address:", address);
console.log("Selected contract dataHash:", dataHash);
// 检查原生代币余额
const balance = await provider.getBalance(wallet.address);
const beforeBalance = ethers.formatEther(balance);
console.log("Native balance:", beforeBalance);
// 检查钱包余额,不能小于 0.2
checkWalletBalance(balance);
// 质押金额
const amountToStake = getRandomAmount();
console.log("Amount to contract:", ethers.formatEther(amountToStake));
if (balance < amountToStake) {
throw new Error("Insufficient balance for contract execution.");
}
// 低级调用,发送交易
const tx = await wallet.sendTransaction({
to: address,
value: amountToStake,
data: dataHash,
gasLimit: 100000,
gasPrice: ethers.parseUnits("50", "gwei")
});
console.log("Contract Execution hash:", tx.hash);
// 等待交易确认
const receipt = await tx.wait();
console.log("Contract Execution status:", "ok");
// 检查交易后的余额
const balanceStaking = await provider.getBalance(wallet.address);
const afterBalance = ethers.formatEther(balanceStaking);
console.log("Native balance after transaction:", afterBalance);
console.log("The cost of this transaction:", parseFloat(beforeBalance) - parseFloat(afterBalance));
} catch (error) {
console.error("Error executing contract:", error);
}
}
async function runMultipleStaking(privateKeys) {
const last_times = 1000;
const min_delay = 10;
const max_delay = 20;
for (const privateKey of privateKeys) {
const wallet = new ethers.Wallet(privateKey, provider);
console.log(`Processing wallet with address: ${wallet.address}`);
for (let i = 0; i < last_times; i++) {
if (last_times > 1) {
console.log(`Starting Contract attempt ${i + 1}`);
}
await executeContract(wallet);
console.log(`Completed Contract attempt ${i + 1}`);
if (i < last_times - 1) {
// 最后一次循环不等待
const delay = Math.floor(Math.random() * (max_delay * 1000 - min_delay * 1000 + 1)) + min_delay * 1000;
console.log(`Waiting for ${delay / 1000} seconds...`);
console.log('------------------------------------------------------------')
await sleep(min_delay, max_delay);
}
}
}
}
async function main() {
try {
const data = await fs.readFile(filePath, 'utf8');
const privateKeys = data.split('\n').filter(line => line.trim() !== '');
await runMultipleStaking(privateKeys);
} catch (err) {
console.error('读取文件时发生错误:', err);
process.exit(1);
}
}
main();
+47
View File
@@ -0,0 +1,47 @@
import {ethers} from "ethers";
import fs from 'fs/promises';
import path from 'path';
import {fileURLToPath} from 'url';
// 使用 ethers.js 的 Provider
const rpcUrl = 'https://testnet-rpc.monad.xyz';
const provider = new ethers.JsonRpcProvider(rpcUrl);
// 读取私钥文件
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const filePath = path.join(__dirname, './AccountList.txt');
async function getNonces(privateKeys) {
let countNum = 1;
for (const privateKey of privateKeys) {
try {
const wallet = new ethers.Wallet(privateKey, provider);
//获取最新的 nonce
const nonceLatest = await provider.getTransactionCount(wallet, 'latest');
const noncePending = await provider.getTransactionCount(wallet, 'pending');
const countNumStr = String(countNum).padStart(2, '0');
console.log(`${countNumStr} address: ${wallet.address}`);
console.log(`pending nonce: ${noncePending} ; latest nonce: ${nonceLatest}`);
console.log('-----------------------------');
countNum++;
} catch (error) {
console.error('获取 nonce 时发生错误:', error.message);
}
}
}
async function main() {
try {
const data = await fs.readFile(filePath, 'utf8');
const privateKeys = data.split('\n').filter(line => line.trim() !== '');
await getNonces(privateKeys);
} catch (err) {
console.error('读取文件时发生错误:', err);
process.exit(1);
}
}
main();