web3.eth.abi.decodeLog(inputs, hexString, topics) 函数中 inputs 如何获取

官方的Demo是这样的。文档中有提到,第一个参数是 json 格式的参数,就是需要解码的数据类型。问题是这个数据类型怎么获取。

文档地址:https://web3js.readthedocs.io/en/v1.2.11/web3-eth-abi.html#decodelog

找到对应的合约地址,然后去看相应的函数里面具体是什么类型。

例如:

Chainlink contract transfer event

转移事件

event Transfer(address indexed from, address indexed to, uint256 value);

如果想解码需要的 inputs

[{
    type: 'address',
    name: 'from',
    indexed: true
},{
    type: 'address',
    name: 'to',
    indexed: true
},{
    type: 'uint256',
    name: 'value'
}]

原文:https://ethereum.stackexchange.com/questions/79788/what-is-input-in-web3-eth-abi-decodeloginputs-hexstring-topics

发表评论

邮箱地址不会被公开。 必填项已用*标注