CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-web3

A Python library for interacting with Ethereum blockchain

Overall
score

88%

Evaluation88%

1.01x

Agent success when using this tile

Overview
Eval results
Files

task.mdevals/scenario-3/

Ethereum Account Balance Checker

Build a simple account balance checker that connects to an Ethereum node and retrieves balance information for Ethereum addresses.

Requirements

Your implementation should:

  1. Connect to an Ethereum node using an HTTP provider
  2. Verify that the connection is active
  3. Query the balance of Ethereum addresses in wei
  4. Convert balances from wei to ether
  5. Support ENS name resolution for balance queries

Implementation

@generates

API

class BalanceChecker:
    """
    A class for checking Ethereum account balances.
    """

    def __init__(self, provider_url: str):
        """
        Initialize the balance checker with an Ethereum node URL.

        Args:
            provider_url: HTTP URL of the Ethereum node (e.g., 'http://localhost:8545')
        """
        pass

    def get_balance_wei(self, address: str) -> int:
        """
        Get the balance of an address in wei.

        Args:
            address: Ethereum address or ENS name

        Returns:
            Balance in wei as an integer
        """
        pass

    def get_balance_ether(self, address: str) -> float:
        """
        Get the balance of an address in ether.

        Args:
            address: Ethereum address or ENS name

        Returns:
            Balance in ether as a float
        """
        pass

    def is_connected(self) -> bool:
        """
        Check if the connection to the Ethereum node is active.

        Returns:
            True if connected, False otherwise
        """
        pass

Test Cases

  • The checker can connect to an Ethereum node and verify the connection is active @test
  • Getting the balance of address '0x0000000000000000000000000000000000000000' returns an integer in wei @test
  • Converting a balance from wei to ether returns the correct float value (e.g., 1000000000000000000 wei equals 1.0 ether) @test
  • The balance checker can resolve an ENS name and return its balance @test

Dependencies { .dependencies }

web3 { .dependency }

Provides Ethereum blockchain interaction capabilities including connecting to nodes, querying balances, unit conversion, and ENS resolution.

Install with Tessl CLI

npx tessl i tessl/pypi-web3

tile.json