Error: Returned Error: VM Exception while processing transac



我写了一个智能合约,目的是通过1英寸交换。我已经使用ganache-cli将合同部署到本地分叉的主网,并成功地为我的合同预融资。但是,在执行swap函数时,事务返回以下消息:Error: Returned Error: VM Exception while processing transaction: revert SafeERC20: low-level call failed. 这是我遇到问题的代码:

function swapOnOneInch(
address fromToken,
address toToken,
uint256 originAmount,
uint256 minTargetAmount,
uint256[] memory exchangeDistribution
) internal {
uint minOut = 99 * minTargetAmount / 100;
bytes memory _data = abi.encodeWithSignature(
"swap(address,address,uint256,uint256,uint256[],uint256)",
fromToken,
toToken,
originAmount,
// Set to 99% of the minTargetAmount, to give us a
// 1% price/slippage buffer
minOut,
exchangeDistribution,
0
);
invoke(0x50FDA034C0Ce7a8f7EFDAebDA7Aa7cA21CC1267e, _data);
}

我一直在网上找,找不到一个有用的解决方案。有人知道错误可能在哪里吗?任何帮助都是非常感激的:)

您必须在调用swap之前批准1Split地址。您可能还需要批准1SplitWrap合同地址。

相关内容