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-8/

Contract Function Caller

Build a utility that calls specific versions of overloaded contract functions using function signatures.

Background

Smart contracts can have multiple functions with the same name but different parameters (overloading). For example, a contract might have both getValue() and getValue(uint256). To call the correct version, you must specify the complete function signature.

Task

Create a Python function call_contract_function that:

  1. Takes a Web3 instance, contract address, ABI, function signature, and optional arguments
  2. Calls the specified version of the function using its signature
  3. Returns the result of the call
  4. Raises an exception if the signature doesn't exist in the contract

The function signature should be:

def call_contract_function(w3, contract_address, abi, function_signature, *args):
    """
    Call a contract function by its signature.

    Args:
        w3: Web3 instance
        contract_address: Contract address (string)
        abi: Contract ABI (list)
        function_signature: Function signature like "getValue(uint256)"
        *args: Arguments to pass to the function

    Returns:
        The result from the contract function call
    """

Test Cases

  • Given a contract with overloaded functions getValue() and getValue(uint256), calling the utility with signature "getValue()" should invoke the parameterless version @test
  • Given a contract with overloaded functions getValue() and getValue(uint256), calling the utility with signature "getValue(uint256)" with argument 42 should invoke the parameterized version and return the result @test
  • Given a contract address and a signature that doesn't exist in the contract, the utility should raise an error @test

Dependencies { .dependencies }

web3 { .dependency }

Provides Ethereum blockchain interaction capabilities including contract function resolution by signature.

@generates