web3.eth.abi.decodeParameters
将ABI编码的参数解码为其JavaScript形式。
调用方法
web3.eth.abi.decodeParameters(typesArray, hexString);
参数
typesArray - Array|Object: 参数类型数组,或JSON接口输出数组 hexString - String: 要解码的ABI字节码
返回值
Object - 包含解码后参数值的对象
示例代码
web3.eth.abi.decodeParameters(['string', 'uint256'], '0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000ea000000000000000000000000000000000000000000000000000000000000000848656c6c6f212521000000000000000000000000000000000000000000000000');
> Result { '0': 'Hello!%!', '1': '234' }
web3.eth.abi.decodeParameters([{
type: 'string',
name: 'myString'
},{
type: 'uint256',
name: 'myNumber'
}], '0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000ea000000000000000000000000000000000000000000000000000000000000000848656c6c6f212521000000000000000000000000000000000000000000000000');
> Result {
'0': 'Hello!%!',
'1': '234',
myString: 'Hello!%!',
myNumber: '234'
}