ethereum / web3.py

A python interface for interacting with the Ethereum blockchain and ecosystem.
http://web3py.readthedocs.io
MIT License
4.97k stars 1.69k forks source link

When using"Contract.decode_function_input" , TypeError: 'NoneType' object is not iterable #3426

Closed HasaTan closed 3 months ago

HasaTan commented 3 months ago

What happened?

I am learning by following https://web3py.readthedocs.io/en/v6.20.0/web3.contract.html#web3.contract.Contract.decode_function_input

my code is as follows:

from hexbytes import HexBytes
from web3 import Web3,contract,EthereumTesterProvider
from web3.contract import Contract

    w3 = Web3(Web3.HTTPProvider('https://mainnet.infura.io/v3/xxxxxxx'))
    transaction = w3.eth.get_transaction('0xf32e5a06a8e2929a6b0ae0d5caa423e51340e5fefa1a03def91979f01d063ed5')
    TX_input=transaction.input
    aa=contract.Contract.decode_function_input(TX_input)
    print(aa)

but it may be something wrong:

Traceback (most recent call last):
  File "", line 35, in <module>
    main()
  File "", line 24, in main
    aa=contract.Contract.decode_function_input(TX_input)
  File "", line 31, in _wrapper
    return self.method(objtype, *args, **kwargs)
  File "", line 825, in decode_function_input
    func = self.get_function_by_selector(data[:4])
  File "", line 31, in _wrapper
    return self.method(objtype, *args, **kwargs)
  File "", line 814, in get_function_by_selector
    fns = self.find_functions_by_identifier(
  File "", line 31, in _wrapper
    return self.method(objtype, *args, **kwargs)
  File "", line 546, in find_functions_by_identifier
    find_functions_by_identifier(
  File "", line 245, in find_functions_by_identifier
    fns_abi = filter_by_type("function", contract_abi)
  File "", line 103, in filter_by_type
    return [abi for abi in contract_abi if abi["type"] == _type]
TypeError: 'NoneType' object is not iterable

Code that produced the error

No response

Full error output

No response

Fill this section in if you know how this could or should be fixed

No response

web3 Version

6.20.0

Python Version

3.9

Operating System

win 11

Output from pip freeze

No response