SignIn.mjs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { ethers } from 'ethers';
  2. const providerUrl = 'https://testnet-rpc.monad.xyz';
  3. const provider = new ethers.JsonRpcProvider(providerUrl);
  4. const privateKeyList = [
  5. '0x3991542110242368f4770716be904b0ca6d44a8dbe4501771833b1a3642198d1'
  6. ];
  7. const stakingContractAddress = '0xcBE623D259261FFa0CFAff44484bFF46c1b7D6c2';
  8. // Function to generate random delay between 5-10 seconds
  9. const getRandomDelay = () => {
  10. return Math.floor(Math.random() * (10000 - 5000 + 1)) + 5000;
  11. };
  12. // Function to handle staking for a single wallet
  13. async function stakeMon(wallet) {
  14. try {
  15. const balance = await provider.getBalance(wallet.address);
  16. console.log(`Wallet ${wallet.address} balance:`, ethers.formatEther(balance));
  17. // 签到合约, 金额设置 0
  18. const amountToStake = ethers.parseEther('0');
  19. if (balance < amountToStake) {
  20. throw new Error(`Insufficient balance for staking in wallet ${wallet.address}`);
  21. }
  22. const tx = await wallet.sendTransaction({
  23. to: stakingContractAddress,
  24. value: amountToStake,
  25. data: '0x7ab71841',
  26. gasLimit: 1000000,
  27. gasPrice: ethers.parseUnits('52', 'gwei')
  28. });
  29. console.log(`Stake transaction hash for ${wallet.address}:`, tx.hash);
  30. const receipt = await tx.wait();
  31. console.log(`Stake transaction receipt for ${wallet.address}:`, receipt);
  32. } catch (error) {
  33. console.error(`Error staking $MON for ${wallet.address}:`, error);
  34. }
  35. }
  36. // Function to process all wallets with delay
  37. async function processAllWallets() {
  38. for (const privateKey of privateKeyList) {
  39. const wallet = new ethers.Wallet(privateKey, provider);
  40. await stakeMon(wallet);
  41. // Add random delay between 5-10 seconds, except for the last wallet
  42. if (privateKey !== privateKeyList[privateKeyList.length - 1]) {
  43. const delay = getRandomDelay();
  44. console.log(`Waiting ${delay/1000} seconds before next wallet...`);
  45. await new Promise(resolve => setTimeout(resolve, delay));
  46. }
  47. }
  48. }
  49. processAllWallets();