问题描述
如何解码 trongrid API 返回值? 我读过这篇文章:https://developers.tron.network/docs/parameter-and-return-value-encoding-and-decoding 做了类似的事情,但我得到了错误:
core.js:5980 ERROR Error: Uncaught (in promise): Error: invalid arrayify value (argument="value",value="000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000",code=INVALID_ARGUMENT,version=bytes/5.0.9)
我的代码:
import { ethers } from 'ethers';
const AbiCoder = ethers.utils.AbiCoder;
const types = "[{ name: '',type: 'uint256[]' }]";
// const types = "['uint256[]']"; - doesn't work as well
// const types = "uint256[]"; - doesn't work as well
// const types = "['uint256[]']"; - doesn't work as well
// const types = "['uint256']"; - doesn't work as well
const output = '000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000';
const abiCoder = new AbiCoder();
abiCoder.decode(types,output);
console.log('unreached statement');
来自阿比:
{
constant: true,inputs: [],name: 'getAvailableCycles',outputs: [{ name: '',type: 'uint256[]' }],payable: false,stateMutability: 'view',type: 'function',},
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)