OP 02 February, 2024 - 12:13 PM
Seed-Mnenonic-phrase-checker-for-ETH.py
Code:
import requests
from eth_account import Account
import time
import json
Account.enable_unaudited_hdwallet_features()
def load_config():
try:
with open('config.json', 'r') as config_file:
config = json.load(config_file)
return config
except Exception as e:
print(f"Error loading configuration: {e}")
return None
def get_wallet_balance(address, etherscan_api_key, proxies=None):
try:
url = f"https://api.etherscan.io/api?module=account&action=balance&address={address}&tag=latest&apikey={etherscan_api_key}"
response = requests.get(url, proxies=proxies)
data = response.json()
balance_in_wei = int(data['result'])
balance_in_eth = balance_in_wei / 1e18 # Convert Wei to Ether
return balance_in_eth
except Exception as e:
print(f"Error fetching balance for address {address}: {e}")
return None
def check_balances(file_path, etherscan_api_key, output_file, proxies=None):
with open(file_path, 'r') as file:
seed_phrases = set(file.readlines()) # Using a set to remove duplicates
print("Starting balance check...")
with open(output_file, 'a') as out_file: # Change to append mode
for seed in seed_phrases:
seed = seed.strip()
if seed:
try:
wallet = Account.from_mnemonic(seed)
print(f"Checking wallet: {wallet.address}")
balance = get_wallet_balance(wallet.address, etherscan_api_key, proxies=proxies)
if balance is not None and balance > 0:
print(f"Success: Address {wallet.address} has a balance of {balance:.18f} ETH.")
out_file.write(f"Seed: {seed}\nAddress: {wallet.address}\nBalance: {balance:.18f} ETH\n\n")
elif balance is not None:
print(f"Address {wallet.address} has zero balance.")
time.sleep(0.2) # Delay to avoid hitting the rate limit
except Exception as e:
print(f"Error with seed phrase '{seed}': {e}")
print("Balance check completed.")
if __name__ == "__main__":
config = load_config()
if config:
etherscan_api_key = config.get("etherscan_api_key", "")
input_file_path = config.get("input_file_path", "")
output_file_path = config.get("output_file_path", "")
proxies = config.get("proxies", None)
if etherscan_api_key and input_file_path and output_file_path:
check_balances(input_file_path, etherscan_api_key, output_file_path, proxies=proxies)
else:
print("Invalid configuration. Please check your config.json file.")
else:
print("Failed to load configuration. Exiting.")
Config.json
Code:
{
"etherscan_api_key": "YOUR API KEY",
"input_file_path": "Seeds.txt",
"output_file_path": "GoodS.txt",
"proxies": {
"http": "http://your_http_proxy",
"https": "https://your_https_proxy"
}
}