Skip to content

Unhandled ValueError when calling contract functions #1864

@ml31415

Description

@ml31415

Version: master

What was wrong?

Whenever a contract function call fails, for whatever reason, it throws an unspecified ValueError, which pops up through all the call stack. For libraries on top it's not possible to properly reason and deal with such an unspecific error. This problem shows up in a lot of issue reports, e.g. #1725 #1717 #651 and nosofa/uniswap-v2-py#10 .

How can it be fixed?

To my humble understanding, this should best be handled somewhere in call_contract_function()

def call_contract_function(
. E.g. in
raise BadFunctionCallOutput(msg) from e
the function nicely throws a perfectly understandable BadFunctionCallOutput. Imho the two function calls in
return_data = web3.eth.call(call_transaction)
and below should probably also be wrapped with a try-except-clause and throw BadFunctionCallOutput or another more specific error.

Another and maybe even the better option might be, to replace all the ValueError and KeyError in https://github.com/ethereum/web3.py/blob/master/web3/manager.py with some kind of server side response error right away.

Metadata

Metadata

Assignees

No one assigned

    Labels

    v7breaking changes considered for v7

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions