// SPDX-License-Identifier: MIT
pragma solidity >= 0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract C {
function deposit( uint amount, IERC20 _token)
public
{
_token.transferFrom(msg.sender,address(this), amount);
_token.transfer(address(this), amount);
}
}
deposit 方法中,使用transfer和transferFrom都会报错. 前面已经进行过approve了, 调用deposit的地址也有代币.