Web3 python:如何解码输入数据

Pen*_*kar 8 python python-3.x blockchain ethereum web3py

使用 web3 (python3) 我正在尝试解码 BSC 交易的输入数据,如 BscScan 上所示 在此输入图像描述

在一些解决方案中,我发现正在使用以下代码:

import web3
from web3.contract import Contract
...
contract = web3.eth.contract(address=Web3.toChecksumAddress(tokenAddress), abi=abi)
contract.functions.decode_function_input(transaction.input)
Run Code Online (Sandbox Code Playgroud)

但是,abi 似乎没有定义此函数“decode_function_input”,因为我收到错误:

"web3.exceptions.ABIFunctionNotFound: ("The function 'decode_function_input' was not found in this contract's abi. ", 'Are you sure you provided the correct contract abi?')"
Run Code Online (Sandbox Code Playgroud)

我 100% 认为 abi 是正确的。此外,在 BscScan 合约原始视图中,函数“decode_function_input”确实不存在。

还有其他解决方案,如何解码输入数据

小智 1

不是contract.functions.decode_function_input,是contract.decode_function_input()