Advertisement
Guest User

etherscan_auto_1.1.py

a guest
Jan 7th, 2021
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.51 KB | None | 0 0
  1. import json
  2. import requests
  3. import time
  4. from ecdsa import SigningKey, SECP256k1
  5. import sha3
  6.  
  7. '''
  8. RUN
  9. pip install ecdsa
  10. AND
  11. pip install sha3
  12. BEFORE YOU RUN THE SCRIPT FOR THE FIRST TIME
  13. LIMITS: 20 keys per request, 5 requests per second
  14. made by @subvert (tg), i'd be grateful if you sent me a tiny bit of your booty after you got rich
  15. '''
  16.  
  17. ETHERSCAN_API = '' # insert your API KEY from etherscan.io here
  18.  
  19.  
  20. def main(print_empty=False):
  21.     wallets = []
  22.    
  23.     while len(wallets) < 21:
  24.         wallet = {}
  25.         wallet['private_key'], wallet['public_key'], wallet['address'] = generate_address()
  26.         wallets.append(wallet)
  27.    
  28.     addresses_to_check = ','.join(wallet['address'] for wallet in wallets)
  29.    
  30.     for address, balance in check_balance(addresses_to_check):
  31.         if balance == '0' and not print_empty:
  32.             continue
  33.         else:
  34.             for wallet in wallets:
  35.                 if wallet['address'] == address:
  36.                     print(f'MONEY FOUND: {balance} at {wallet}')
  37.            
  38. def generate_address():
  39.     keccak = sha3.keccak_256()
  40.     private_key = SigningKey.generate(curve=SECP256k1)
  41.     public_key = private_key.get_verifying_key().to_string()
  42.     keccak.update(public_key)
  43.     address = keccak.hexdigest()[24:]
  44.     return private_key.to_string().hex(), public_key.hex(), checksum_encode(address)
  45.  
  46. def checksum_encode(addr_str): # hex str
  47.     keccak = sha3.keccak_256()
  48.     out = ''
  49.     addr = addr_str.lower().replace('0x', '')
  50.     keccak.update(addr.encode('ascii'))
  51.     hash_addr = keccak.hexdigest()
  52.    
  53.     for i, c in enumerate(addr):
  54.         if int(hash_addr[i], 16) >= 8:
  55.             out += c.upper()
  56.         else:
  57.             out += c
  58.     return '0x' + out
  59.  
  60. def check_balance(addresses): # str commaseparated
  61.     params = {'module': 'account',
  62.               'action': 'balancemulti',
  63.               'address': addresses,
  64.               'apikey': ETHERSCAN_API
  65.             }
  66.    
  67.     while True:
  68.         r = requests.get('https://api.etherscan.io/api', params=params)
  69.         response = json.loads(r.text)
  70.        
  71.         if response['status']:
  72.             for address in response['result']:
  73.                 yield address['account'], address['balance']
  74.                            
  75.             break
  76.        
  77.         else:
  78.             print(f'ERROR: {response["result"]}')
  79.  
  80. if __name__ == '__main__':
  81.     while True:
  82.         main(print_empty=False) #change to True if you want empty wallets to be printed
  83.         time.sleep(0.22)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement