我是新来的,我正在尝试将令牌从“地址 A”交换到“地址 B”。
我使用了函数approval和transferFrom,但我仍然收到错误:“错误:处理交易时出现VM异常:使用原因字符串'BEP20:转账金额超过限额'恢复”
你能帮我解决这个问题吗?
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.3;
import "./CryptoPlinkoBall.sol";
import "./CryptoPlinko.sol";
import "hardhat/console.sol";
contract TokenSwap {
address admin;
address public owner;
address private _token;
constructor(address token) {
admin = msg.sender;
_token = token;
}
function swapTokens(address recipient, uint256 amount) external {
BEP20(_token).approve(msg.sender, amount);
BEP20(_token).allowance(msg.sender, address(this));
BEP20(_token).transferFrom(msg.sender, recipient, amount);
}
}