├── README.md └── eth_wallet_tracking_tutorial.py /README.md: -------------------------------------------------------------------------------- 1 | # Ethereum-Wallet-Tracker 2 | Track ethereum balance and transactions using Python. 3 | 4 | 5 | # 💻 Launch Your Software Development Career Today! 6 | 7 | 🎓 **No degree? No problem!** My program equips you with everything you need to break into tech and land an entry-level software development role. 8 | 9 | 🚀 **Why Join?** 10 | - 💼 **$70k+ starting salary potential** 11 | - 🕐 **Self-paced:** Complete on your own time 12 | - 🤑 **Affordable:** Low risk compared to expensive bootcamps or degrees 13 | - 🎯 **45,000+ job openings** in the market 14 | 15 | 👉 **[Start your journey today!](https://techwithtim.net/dev)** 16 | No experience needed—just your determination. Future-proof your career and unlock six-figure potential like many of our students have! 17 | -------------------------------------------------------------------------------- /eth_wallet_tracking_tutorial.py: -------------------------------------------------------------------------------- 1 | from requests import get 2 | from matplotlib import pyplot as plt 3 | from datetime import datetime 4 | 5 | API_KEY = "PNGXQK3MZZ17S5M41G6D8K5X8Z5Y6U524Q" 6 | BASE_URL = "https://api.etherscan.io/api" 7 | ETHER_VALUE = 10 ** 18 8 | 9 | def make_api_url(module, action, address, **kwargs): 10 | url = BASE_URL + f"?module={module}&action={action}&address={address}&apikey={API_KEY}" 11 | 12 | for key, value in kwargs.items(): 13 | url += f"&{key}={value}" 14 | 15 | return url 16 | 17 | def get_account_balance(address): 18 | balance_url = make_api_url("account", "balance", address, tag="latest") 19 | response = get(balance_url) 20 | data = response.json() 21 | 22 | value = int(data["result"]) / ETHER_VALUE 23 | return value 24 | 25 | def get_transactions(address): 26 | transactions_url = make_api_url("account", "txlist", address, startblock=0, endblock=99999999, page=1, offset=10000, sort="asc") 27 | response = get(transactions_url) 28 | data = response.json()["result"] 29 | 30 | internal_tx_url = make_api_url("account", "txlistinternal", address, startblock=0, endblock=99999999, page=1, offset=10000, sort="asc") 31 | response2 = get(internal_tx_url) 32 | data2 = response2.json()["result"] 33 | 34 | data.extend(data2) 35 | data.sort(key=lambda x: int(x['timeStamp'])) 36 | 37 | current_balance = 0 38 | balances = [] 39 | times = [] 40 | 41 | for tx in data: 42 | to = tx["to"] 43 | from_addr = tx["from"] 44 | value = int(tx["value"]) / ETHER_VALUE 45 | 46 | if "gasPrice" in tx: 47 | gas = int(tx["gasUsed"]) * int(tx["gasPrice"]) / ETHER_VALUE 48 | else: 49 | gas = int(tx["gasUsed"]) / ETHER_VALUE 50 | 51 | time = datetime.fromtimestamp(int(tx['timeStamp'])) 52 | money_in = to.lower() == address.lower() 53 | 54 | if money_in: 55 | current_balance += value 56 | else: 57 | current_balance -= value + gas 58 | 59 | balances.append(current_balance) 60 | times.append(time) 61 | 62 | plt.plot(times, balances) 63 | plt.show() 64 | 65 | 66 | address = "0x73bceb1cd57c711feac4224d062b0f6ff338501e" 67 | get_transactions(address) 68 | --------------------------------------------------------------------------------