Build Ethereum Balance Checker in Python

Build Ethereum Balance Checker in Python

In this guide, we will create an Ethereum balance checker with only 6 lines of code in Python!


2 min read

There are ample blockchain explorers online to query Ethereum wallet balance. But have you ever thought of checking the ETH balance directly from your command-line in a couple of steps? Let's create a tool for that with only 6 lines of code! ๐Ÿ˜Ž


pip install web3
  • Ethereum Node API Endpoint
    Though there are many Ethereum node service providers available online, we'll use Pocket Network for our project as it is free.

    1. Signup for an account at and verify your email address to get access to the endpoints.

    2. Select Apps from the side menu and click Create.

    3. Enter desired App Name and click Launch Application.

    4. Copy the Endpoint provided. (Ensure that Ethereum Mainnet is selected as the Endpoint network!

The web3 library will allow us to interact with the Ethereum blockchain through the API endpoint.

Let's Code!

  1. Import required modules
from web3 import Web3, HTTPProvider
  1. Save the endpoint URL in a variable
  1. Make a connection to Ethereum blockchain through the endpoint
connection = Web3(HTTPProvider(endpoint))
  1. Get the wallet address input from the user
address = input("Enter ETH wallet address: ")
  1. Fetch the latest ETH balance from the blockchain and convert it to ether denomination.
balance = connection.fromWei(connection.eth.getBalance(address, 'latest'), 'ether')
  1. Display the balance
print(f"Balance: {balance} ether")

Save the file; run it; enter ETH address and get your balance right in the terminal. That simple!


So, what's your balance? ๐Ÿ˜