or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/web3@7.13.x
tile.json

tessl/pypi-web3

tessl install tessl/pypi-web3@7.13.0

A Python library for interacting with Ethereum blockchain

Agent Success

Agent success rate when using this tile

88%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.01x

Baseline

Agent success rate without this tile

87%

task.mdevals/scenario-1/

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.