Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Ethereum Blockchain Explorer

Overview

This Python script is a simple blockchain explorer that connects to a public Ethereum node via Infura. It allows users to:

  • Fetch the latest block number.
  • Retrieve transactions from the latest block.
  • Check the balance of a given Ethereum address.

Prerequisites

Ensure you have the following installed on your system:

  1. Python 3.x: Install it from Python's official website.
  2. Web3.py: This library allows interaction with the Ethereum blockchain. Install it using:
    pip install web3
  3. Infura Account: You need an Infura project ID to connect to the Ethereum network. Create a free account at Infura and generate a project ID.

Setup & Configuration

  1. Clone or download this repository.
  2. Open the ethereum_explorer.py file and replace YOUR_INFURA_PROJECT_ID with your actual Infura project ID.
  3. Save the file.

Running the Script

To execute the script, follow these steps:

  1. Open a terminal or command prompt.
  2. Navigate to the directory where ethereum_explorer.py is located.
  3. Run the script using:
    python3 ethereum_explorer.py

Expected Output

When you run the script, you should see output similar to:

Latest Block Number: 21932407
Number of Transactions in Latest Block: 133
Transaction Summary:
{'hash': 'd88d259ffbc4f355366d2e555d9dfb5606f68374201a82cb2798b52899cab9ce', 'from': '0x7049a18279500a25864c509137d7de4ff0048957', 'to': '0x3B55732F6D3997A7D44A041b8496e1A60712A35F', 'value': 0}
{'hash': 'fa36bf69b0615d59c1ee250afdfda766f21d6d1d8fa9021cca50bef758777027', 'from': '0xb36ce3F521a1FF4B0CffB82DDd71F0a51fCf56ce', 'to': '0x51C72848c68a965f66FA7a88855F9f7784502a7F', 'value': 0}
{'hash': '0ab956cee51adf6e56443da4a48cfd5c02523cf4a9aefc9289082015588f67ba', 'from': '0x6f0A91Ef8Adeb54DB0E63BE507747aB9a31d3926', 'to': '0x51C72848c68a965f66FA7a88855F9f7784502a7F', 'value': 0}
.....
Balance of 0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe: 2.345 ETH

Troubleshooting

  • Connection Issues: Ensure you have an active internet connection and that your Infura project ID is correctly set.
  • Module Not Found: If you get an error related to web3, reinstall it using pip install web3.
  • Invalid Address: Ensure the Ethereum address you check is valid.

Future Improvements

  • Add support for querying transactions by hash.
  • Display detailed transaction information.
  • Support multiple Ethereum networks (Mainnet, Ropsten, Goerli, etc.).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages