smartcontracts - 实施 UniswapV2 swapExactTokensForETH 失败
问题描述
在智能合约集成/实施交换之后,我的联系人喜欢下面
contract UniDemo {
function swapTokensForETH(uint amountIn, uint amountOutMin, uint deadline) public payable returns(uint) {
// transfer
require(Token.transferFrom(msg.sender, address(this), amountIn), 'transferFrom failed.');
// approve
require(Token.approve(UNISWAP_ROUTER_ADDRESS, amountIn), 'approve failed.');
// swap
uint[] memory outs = uniswapRouter.swapExactTokensForETH(amountIn, amountOutMin, getPathForTokenToETH(), msg.sender, deadline);
return outs[1];
}
}
我不断收到 EVM 还原错误,这是有问题吗?
发送示例:0x080555abe5287a8e7d67a9129e9464d2773955371fd9ffcf6e81b301d0a7f4df
解决方案
看起来您没有收到来自路由器 (uniswapRouter) 的任何响应,因此当您的数组为空时,returnouts[1]
会引发恢复错误。outs
推荐阅读
- shopify - 从源代码中删除不必要的行空格
- jmeter - 是否可以读取与 jmeter 中的正则表达式匹配的 JSON JMESPath 提取器形式的所有值?
- android - 具有两个 Recyclerview 的 LinearLayout 不根据行数据共享空间
- node.js - 在 nodejs 中通过 aws-sdk 通过 api 创建处于停止状态的 EC2 实例
- python - Python中D维的蒙特卡罗积分
- php - 从出生日期获取日期范围
- mysql - 我如何按 book_id 和 order_id 汇总金额组
- python-3.x - Pandas 将每个单元格的列转换为 ndarray 以在每个单元格中列出
- python - 如何将锁应用于python中的整个读写操作?
- solidity - GameFi中价格滑点的处理策略