Skip to main content

EtherLens is a Python library designed to provide comprehensive insights into Ethereum transactions

Project description

Etherlens

EtherLens is a Python library designed to provide comprehensive insights into Blockchain transactions, token balances, and gas balances associated with a specific address. This library offers a range of functionalities, including decoding transactions made by an address, fetching token balances for various ERC-20 tokens, and retrieving gas balances.

Key Feature

  • Transaction Decoding: Decode any blockchain (ETH,BSC,ARB,OP,BASE,POLY) transaction that contain similar uniswap V2 router functions and universal router like function.It gives insight on token bought,token sold,amount bought,amount sold,hash of the transction
  • Token Balance Fetching: Fetch token balances associated with a given blockchain address for a wide range of ERC-20 tokens, allowing users to quickly ascertain their token holdings.
  • Gas Balance Retrieval: Retrieve gas balances associated with an Ethereum address, enabling users to monitor gas usage and ensure efficient management of gas resources.

Caution

⚠ This library has not been audited, and there is no pledge for one !

⚠ Might be of advantage to be familiar with general blockchain concepts and web3.py in particular.

⚠ This project is a work in progress so not all swap transaction are decoded yet.

Installation

It is recommended to use Python virtual environments, here is a tutorial inorder for the dependencies not to conflict with any other Dependencies you might have in your system

# install the Etherlens from pypi.org
pip install Etherlens

Utilization

This Library exposes a class Observe which has hpublic method that can be use to decode address transction,get token address balance,fetch native gas balance and more

How to decode/get address transaction detail, assuming it swapped on uniswap/sushi or any dapp with similar V2 router contract functions

You can pass in only one address or list of addresses to the method

Blockchain usage

During instantiation of the class Observe user should specify which blockchain he/she wants eg 'ETH','BSC','BASE','OP','ARB','POLY'

from etherlens import Observe

Your_rpc_url = 'https://.......'
Decode = Observe(Your_rpc_url,'ETH')
Address = ['0x82D55805Cd58E908772025F3f32AE55B0eD93143','0x26cE34d34724428138F2E5a6a5B5B95ad8e64f6C']
Output = Decode.monitor(Address)
print(Output)

Example of Output returned by the monitor( ):

{'Address(0x15deac498767a6e997c007ca91df55cbdd8a6198)': [
 {'hash(0x0ba00128c137225647c6e264659f156bde27eafb6133a2e89cfa450ea9eda5d2)':
                                                        {'amountIn': 321551417590518774759424,
                                                          'aountOut': 24405654217389512,
                                                            'tokenIn': '0xfEA9DcDc9E23a9068bF557AD5b186675C61d33eA',
                                                        'tokenOut': '0x4200000000000000000000000000000000000006'}},
'Address(0xc633843de683ff3e91353412b039b0699fa1615b)': [
{'hash(0x53633f8e720ba4f22387ff1e34dac802c07dd9b7ec5b1963b755ff99edf9c15e)':
                                                        {'ammountIn': 26697410107434513,
                                                          'amountOut': 1579868553164855380085,
                                                          'tokenIn': '0x4200000000000000000000000000000000000006',
                                                          'tokenOut': '0xBd59400A7b2062E6a4F64AbbE99D046Fe226757C'}}, {'hash(0xeafc84e5cb41260e32cdd094092b6e4e9189e3e813a4d56e9893b36ca13911b8)':
                                                        {'ammountIn': 1681333259230206230528,
                                                          'amountOut': 3864771106922855,
                                                            'tokenIn': '0xBd59400A7b2062E6a4F64AbbE99D046Fe226757C',
                                                              'tokenOut': '0x4200000000000000000000000000000000000006'}}]}

Get Swap detail with hash

hash = '0x53633f8e720ba4f22387ff1e34dac802c07dd9b7ec5b1963b755ff99edf9c15e'
output = Decode.monitor_with_hash(hash)
print(output)

Example of Output Returned by monitor_with_hash( )

{'hash(0x53633f8e720ba4f22387ff1e34dac802c07dd9b7ec5b1963b755ff99edf9c15e)': {'ammountIn': 26697410107434513, 'amountOut': 1579868553164855380085, 'tokenIn': '0x4200000000000000000000000000000000000006', 'tokenOut': '0xBd59400A7b2062E6a4F64AbbE99D046Fe226757C'}}

Retrive Address/Addresses token(ERC20) balance

tokenContractAddress = '0x9DE16c805A3227b9b92e39a446F9d56cf59fe640'
Address = ['0x08c03a6b5d51a8915bae08a0f182dab6fb2c059b','0x94661f0b3619072c6ce591534e95019a4a3f7ad5'] # you can use a string of address too eg addresss = '0x08c03a6b5d51a8915bae08a0f182dab6fb2c059b'
output = Decode.token_balance(tokenContractAddress,Address)
print(output)

Example of output Returned by token_balance( ):

{'0x08c03a6b5d51a8915bae08a0f182dab6fb2c059b': 1476352034707.0415, '0x94661f0b3619072c6ce591534e95019a4a3f7ad5': 1408145648317.3828}

Retrive Address Eth/native gas balance

Address = ['0x15deac498767a6e997c007ca91df55cbdd8a6198','0x94661f0b3619072c6ce591534e95019a4a3f7ad5']
output = Decode.eth_balance(Address)
print(output)

Example of Output Returned by eth_balance( ):

{'0x15deac498767a6e997c007ca91df55cbdd8a6198': 0.001072, '0x94661f0b3619072c6ce591534e95019a4a3f7ad5': 0.039995}

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

etherlens-0.0.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

Etherlens-0.0.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file etherlens-0.0.1.tar.gz.

File metadata

  • Download URL: etherlens-0.0.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for etherlens-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f26013f633a88d6cf126fad501c5de635e8ceedbe26976261a92f4bdaac5eea7
MD5 9c88d3bc634a68d70b6f759f9f164b4f
BLAKE2b-256 704b29c29677305cd5f8618dfc2fe1e23b5e11750c5a704aec498bbc2015ebdc

See more details on using hashes here.

File details

Details for the file Etherlens-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: Etherlens-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for Etherlens-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5b837e062411c98fba2bd199bd7d62af7159cfadcaa7c9484c38aa3ab44f3c9a
MD5 cd7da982c0c9a60c54d004d0ff0434ff
BLAKE2b-256 5a96a0059bea94648aaae8a46e503b11e05f2c104b499615b91d16aebb0f8f3d

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