googole2

Untitled

Aug 21st, 2024 (edited)
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | Cryptocurrency | 0 0
  1. import os
  2. import requests
  3. from eth_account import Account
  4.  
  5. # Generate a random private key
  6. def generate_private_key():
  7. return os.urandom(32).hex()
  8.  
  9. # Derive address from private key
  10. def private_key_to_address(private_key):
  11. return Account.from_key(private_key).address
  12.  
  13. # Check balance of address using Infura API
  14.  
  15. private_key_ETH = '1926b59bf5ac1863084b1c37a88d280c9843cc3d855b5a65ccac0dde69e45c39'
  16.  
  17. def get_balance(address):
  18. api_key = "cec17ce1af8446de9046be035d8c96a4"# Replace this with your Infura API key
  19. url = f"https://mainnet.infura.io/v3/{api_key}"
  20. data = {"jsonrpc":"2.0","method":"eth_getBalance","params":[address,"latest"],"id":1}
  21. response = requests.post(url, json=data)
  22. balance_wei = int(response.json()["result"], 16)
  23. return balance_wei / 10**18 # Convert from wei to ether
  24.  
  25. # Main function to generate private keys, check balances, and stop when non-zero balance is found
  26. def main():
  27. while True:
  28. private_key = generate_private_key()
  29. address = private_key_to_address(private_key)
  30. balance = get_balance(address)
  31. print("Private Key:", private_key)
  32. print("Address:", address)
  33. print("Balance (ETH):", balance)
  34. if balance > 0:
  35. print("Found a non-zero balance. Stopping...")
  36. break
  37.  
  38. if __name__ == "__main__":
  39. main()
Add Comment
Please, Sign In to add comment