萌新,刚接触不久,我写个了合约需要在合约内获取某个交易对的价格,
我通过https://www.sunswap.com/docs/sunswapV2-interfaces_cn.pdf官方文档中的
router 合约中的方法getAmountsOut
方法来获得,但是一直报错呢?
pragma solidity ^0.5.0;
import "./ISunswapV2Router01.sol";
contract Test {
ISunswapV2Router01 router;
address a;
address b;
constructor(ISunswapV2Router01 _router,address _a,address _b) public {
router = _router;
a = _a;
b = _b;
}
function getTokenPrice(uint total) public view returns (uint[] memory amount1){
address[] memory path;
path[0] = a;
path[1] = b;
amount1 = router.getAmountsOut(total,path);
return amount1;
}
}
ISunswapV2Router01.sol是直接复制的官方文档中的
有大佬给解答下吗?能麻烦给个调用示例吗?感激不尽!