我想在我的智能合约中使用swapExactETHForTokens
,总是失败事务,错误为"execution reverted: UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT"
。
这是我的密码。
pragma solidity ^0.6.2;
interface IUniswap {
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function WETH() external pure returns (address);
}
contract MyDefi{
IUniswap uniswap;
constructor(address _uniswap) public {
uniswap = IUniswap(_uniswap);
}
function tastSwapExactETHForTokens(
uint amountOut,
address token,
uint deadline
) external payable {
address[] memory path = new address[](2);
path[0] = uniswap.WETH();
path[1] = token;
uniswap.swapExactETHForTokens(
amountOut,
path,
msg.sender,
deadline
);
}
}
我试图在rinkeby网络中交换DAI令牌,但我从etherscan网站得到了一个amountOut
论点。https://rinkeby.etherscan.io/address/0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D#readContract
有人帮我解决问题吗?
如果您正在进行混音,则值应不同于0。