├── README.md └── 批量归集.py /README.md: -------------------------------------------------------------------------------- 1 | 用于将EVM钱包地址进行批量归集 2 | 3 | 前置条件:需要创建Excel 表格,对应列创建 transfer address private 信息 4 | 5 | 对于已经发送交易的地址会标注1,用以跳过检测,未发送交易的地址会标注0 6 | 7 | 可以手动修改时间,自由输入合约地址和接收地址 8 | -------------------------------------------------------------------------------- /批量归集.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from web3 import Web3 3 | import time 4 | import random 5 | 6 | # 初始化Web3接口和连接到Binance Smart Chain测试网 7 | w3 = Web3(Web3.HTTPProvider('https://data-seed-prebsc-1-s1.binance.org:8545/')) 8 | 9 | # 函数:从Excel文件中加载账户 10 | def load_accounts_from_excel(file_path): 11 | return pd.read_excel(file_path, engine='openpyxl') 12 | 13 | # 函数:将更新后的账户信息保存回Excel文件 14 | def save_accounts_to_excel(df, file_path): 15 | df.to_excel(file_path, index=False, engine='openpyxl') 16 | 17 | # 函数:生成ERC-20代币转账的data字段 18 | def generate_transfer_data(to_address, amount, decimals=18): 19 | method_id = w3.keccak(text="transfer(address,uint256)").hex()[:10] 20 | to_address_hex = to_address.lower().replace('0x', '').rjust(64, '0') 21 | amount_hex = hex(amount * (10 ** decimals))[2:].rjust(64, '0') 22 | return method_id + to_address_hex + amount_hex 23 | 24 | # 函数:获取ERC-20代币余额 25 | def get_token_balance(token_address, wallet_address): 26 | method_id = w3.keccak(text="balanceOf(address)").hex()[:10] 27 | wallet_address_hex = wallet_address.lower().replace('0x', '').rjust(64, '0') 28 | data = method_id + wallet_address_hex 29 | balance = w3.eth.call({'to': token_address, 'data': data}) 30 | return int(balance.hex(), 16) 31 | 32 | # 加载账户信息 33 | file_path = '' # 更新为您的文件路径 34 | df_accounts = load_accounts_from_excel(file_path) 35 | 36 | # 指定接收代币的地址和代币合约地址 37 | recipient_address = '' # 更新为实际接收地址 38 | token_contract_address = '' # 更新为代币合约地址 39 | amount = 5 # 更新为实际转账金额 40 | decimals = 18 # 根据代币实际情况更新 41 | 42 | # 过滤和准备 43 | df_accounts.dropna(subset=['Address'], inplace=True) 44 | df_accounts['transfer'] = df_accounts['transfer'].fillna(0) 45 | 46 | for index, account in df_accounts.iterrows(): 47 | processed_flag = int(account['transfer']) 48 | address = str(account['Address']).strip() 49 | 50 | if processed_flag == 1: 51 | print(f"Account {address} is already processed. Skipping...") 52 | continue 53 | 54 | if not Web3.is_address(address): 55 | print(f"Invalid address {address}. Skipping...") 56 | continue 57 | 58 | balance = get_token_balance(token_contract_address, address) 59 | if balance < amount * (10 ** decimals): 60 | print(f"Insufficient balance in account {address}. Skipping...") 61 | continue 62 | 63 | try: 64 | current_gas_price = w3.eth.gas_price 65 | except: 66 | print("Error fetching current gas price. Using default.") 67 | current_gas_price = w3.to_wei(5, 'gwei') 68 | 69 | # 生成ERC-20代币转账的data字段 70 | data = generate_transfer_data(recipient_address, amount, decimals) 71 | 72 | # 构建交易字典 73 | tx = { 74 | 'chainId': 97, 75 | 'gas': 50000, 76 | 'gasPrice': current_gas_price, 77 | 'nonce': w3.eth.get_transaction_count(account['Address']), 78 | 'to': token_contract_address, 79 | 'value': 0, 80 | 'data': data 81 | } 82 | 83 | # 签名交易 84 | signed_tx = w3.eth.account.sign_transaction(tx, account['PrivateKey']) 85 | 86 | # 发送交易 87 | tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction) 88 | print(f"Transaction sent with hash: {tx_hash.hex()}") 89 | 90 | # 更新DataFrame中的'transfer'列为1,表示已处理 91 | df_accounts.at[index, 'transfer'] = 1 92 | 93 | 94 | # 保存更新后的Excel文件 95 | save_accounts_to_excel(df_accounts, file_path) 96 | 97 | # 随机等待时间以模拟人类操作,防止被节点限制 98 | sleep_time = random.randint(30, 80) 99 | print(f"Waiting for {sleep_time} seconds...") 100 | time.sleep(sleep_time) 101 | --------------------------------------------------------------------------------