Skip to main content

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

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

  1. Ensure sufficient Ethereum node access permissions
  2. Be mindful of Etherscan API rate limits when performing batch analysis
  3. Default ABI may be required for certain special contracts

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

transaction_balance_analyzer-0.1.0.tar.gz (305.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

transaction_balance_analyzer-0.1.0-py3-none-any.whl (304.8 kB view details)

Uploaded Python 3

File details

Details for the file transaction_balance_analyzer-0.1.0.tar.gz.

File metadata

File hashes

Hashes for transaction_balance_analyzer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 727fdeab46e86112257af6ecc47ec24390f1662492537e94eb6a048a2178d214
MD5 d443ea4244265bcc3c2097cae25f8223
BLAKE2b-256 31b8ec58921777294c16bfc40a7fa396c4f7656ca0fa5627ccb617079a57fcb6

See more details on using hashes here.

File details

Details for the file transaction_balance_analyzer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for transaction_balance_analyzer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ff04c0efbc303b3841ad596e73ff2eafe86aac64c104eeba3103d5de43d1f08
MD5 3a9b3ddbfb1edae0c97361c4cf40e035
BLAKE2b-256 aa3414a5ff0746387e1e0c356b7e58a33120bda4ee0226aa35180e5de39b02f3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page