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();