8

想抓取balancer交易所eth的价格,但是一直提示失败

 3 years ago
source link: https://learnblockchain.cn/question/1750
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
想抓取balancer交易所eth的价格,但是一直提示失败 | 登链社区 | 技术问答

想抓取balancer交易所eth的价格,但是一直提示失败

最近遇到一个问题,就是想抓取 balancer 交易所 eth 的价格,使用的是函数
viewSplitExactIn, web3js 中的命令为:
balancer.viewSplitExactIn.call(里面的是参数和回调函数);

但是一直提示这个错误:Error: invalid solidity type!: tuple[]

我使用相同的参与,在 https://etherscan.io/网站上是可以抓取到数据的。

有哪位大神可以帮忙解决一下吗?

Tiny熊 - 布道者 4小时前

  擅长:智能合约,以太坊

参数的类型错误。

viewSplitExactIn 需要什么参数?

你传了什么参数?

mingyue 3小时前

_20210105190451.png

使用 https://etherscan.io 调用的话,可以看到如图这样的。

如下的函数的接口:

function viewSplitExactIn(
    address tokenIn,
    address tokenOut,
    uint swapAmount,
    uint nPools
)
    public view
    returns (Swap[] memory swaps, uint totalOutput)
{}

我调用的时候,使用这个代码:
balancer.viewSplitExactIn.call("0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0x6b175474e89094c44da98b954eedeac495271d0f",1000000000,1,function(error,result){
if(!error)
console.log(result);
else
console.log(error);
});

其中 balancer 是我前面定义的合约实例。

从返回的错误来看,应该是调用到了合约的 viewSplitExactIn 函数,但是返回有问题。 给的错误提示为:Error: invalid solidity type!: tuple[]。

感谢!!!

您需要登录后才可以回答问题,登录 或者 注册

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK