Advertisement
Guest User

Untitled

a guest
Nov 14th, 2023
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. import requests
  2. from eth_account import Account
  3. import time
  4. Account.enable_unaudited_hdwallet_features()
  5.  
  6. def get_wallet_balance(address, etherscan_api_key):
  7. try:
  8. url = f"https://api.etherscan.io/api?module=account&action=balance&address={address}&tag=latest&apikey={etherscan_api_key}"
  9. response = requests.get(url)
  10. data = response.json()
  11. balance_in_wei = int(data['result'])
  12. balance_in_eth = balance_in_wei / 1e18 # Convert Wei to Ether
  13. return balance_in_eth
  14. except Exception as e:
  15. print(f"Error fetching balance for address {address}: {e}")
  16. return None
  17.  
  18. def check_balances(file_path, etherscan_api_key, output_file):
  19. with open(file_path, 'r') as file:
  20. seed_phrases = set(file.readlines()) # Using a set to remove duplicates
  21.  
  22. print("Starting balance check...")
  23. with open(output_file, 'a') as out_file: # Change to append mode
  24. for seed in seed_phrases:
  25. seed = seed.strip()
  26. if seed:
  27. try:
  28. wallet = Account.from_mnemonic(seed)
  29. print(f"Checking wallet: {wallet.address}")
  30. balance = get_wallet_balance(wallet.address, etherscan_api_key)
  31. if balance is not None and balance > 0:
  32. print(f"Success: Address {wallet.address} has a balance of {balance:.18f} ETH.")
  33. out_file.write(f"Seed: {seed}\nAddress: {wallet.address}\nBalance: {balance:.18f} ETH\n\n")
  34. elif balance is not None:
  35. print(f"Address {wallet.address} has zero balance.")
  36. time.sleep(0.2) # Delay to avoid hitting the rate limit
  37. except Exception as e:
  38. print(f"Error with seed phrase '{seed}': {e}")
  39. print("Balance check completed.")
  40.  
  41. # Replace these paths with your actual file paths
  42. seed_file_path = 'seedd.txt'
  43. output_file_path = 'good.txt'
  44. etherscan_api_key = "YOUR_ETHER_API_KEY"
  45.  
  46. check_balances(seed_file_path, etherscan_api_key, output_file_path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement