如何解决尝试解码来自 trongrid 的返回值时出错
如何解码 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 举报,一经查实,本站将立刻删除。