A tool for analyzing account balance changes in Ethereum transactions
Project description
Transaction Balance Analyzer
A tool for analyzing account balance changes in Ethereum transactions. Supports both single and batch transaction analysis, tracking changes in ETH and ERC20 token balances.
Author
-
Tao Yan
-
Email: yan@ifi.uzh.ch
-
Guanda Zhao
-
Email: guanda.zhao@uzh.ch
-
Claudio J.Tessone
-
Email: claudio.tessone@uzh.ch
Features
- Analyzes both external and internal transactions
- Tracks ETH and ERC20 token balance changes of involved addresses
- Automatic proxy contract detection and handling
- Supports batch transaction analysis
- Automatic token decimal handling
- Results output in easy-to-read CSV format for each transaction
Requirements
- Python 3.7+
- Web3.py
- Pandas
Installation
pip install transaction-balance-analyzer
Configuration
Set the following environment variables before use:
export ETH_NODE_URL='your_ethereum_node_url'
export ETHERSCAN_API_KEY='your_etherscan_api_key'
Usage Examples
Basic Usage
from transaction_balance_analyzer import AccountBalanceChangeAnalyzer
import os
# Set environment variables
os.environ['ETH_NODE_URL'] = 'your_ethereum_node_url'
os.environ['ETHERSCAN_API_KEY'] = 'your_etherscan_api_key'
# Initialize analyzer
analyzer = AccountBalanceChangeAnalyzer()
# Analyze single transaction
tx_hash = "0x191aeb75d5ac81c46d97916cb88f9f02b4a6e5f854823beae99dbd6336f18928"
result = analyzer.get_account_balance_change(tx_hash)
print(result)
# Save results to CSV
result.to_csv('analysis_result.csv', index=False)
Batch Analysis
# Analyze multiple transactions
tx_hashes = [
"0x191aeb75d5ac81c46d97916cb88f9f02b4a6e5f854823beae99dbd6336f18928",
"0x40d4a421465acc8d4c63c9175e6858e614b76560fef6f46dd4694e9fba99b674",
"0xb50f927760c2e6b14a969d515a5ceffc5bbb7f5a0685db05c3766a90a01d63df"
]
results = analyzer.analyze_batch_transactions(tx_hashes)
# Print results for each transaction
for tx_hash, result in results.items():
print(f"\nResults for transaction {tx_hash}:")
print(result)
# Save individual results
result.to_csv(f'result_{tx_hash[:10]}.csv', index=False)
Example Output
The analysis results are returned as a pandas DataFrame with the following format:
tx_hash,address,ETH,USDT,WETH
0x123...,0xabc...,-0.5,100.0,0.0
0x123...,0xdef...,0.5,-100.0,0.0
Important Notes
- Ensure sufficient Ethereum node access permissions
- Be mindful of Etherscan API rate limits when performing batch analysis
- Default ABI may be required for certain special contracts
Changelog
0.2.0
- Added USD value conversion feature
- Added all_address_mode parameter
- Optimized address merging logic
- Improved ETH balance calculation
Contributing
Issues and Pull Requests are welcome.
License
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file transaction_balance_analyzer-0.2.0.tar.gz.
File metadata
- Download URL: transaction_balance_analyzer-0.2.0.tar.gz
- Upload date:
- Size: 310.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f73d156130da6a9d2d1d29cbdbf355841961f9c18ee1d033af97fe95e60793da
|
|
| MD5 |
5e9ec7c665491da7d5d988eeae47ba0b
|
|
| BLAKE2b-256 |
4e2ae990e5cdeb743aa019cc8acaad89e642f02ffe54ebbdf7a07e48d1f3ee35
|
File details
Details for the file transaction_balance_analyzer-0.2.0-py3-none-any.whl.
File metadata
- Download URL: transaction_balance_analyzer-0.2.0-py3-none-any.whl
- Upload date:
- Size: 308.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df1b49651ef2356aa95197518247524f089fdf2be35cfbf94f7c963e012cd9ba
|
|
| MD5 |
b42f4ba8b43adb31c901e3d866a47f6e
|
|
| BLAKE2b-256 |
9c9f316e42a6ce034005f47e90077ce1084a14adc825ca3f6cbecd95cfe1d220
|