I'm trying to understand the following code:
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract Recipient {
IERC20 private _token;
event DoneStuff(address from, address to, uint256 amount);
constructor (address token) public {
_token = IERC20(token);
}
function doStuff() external {
address from = msg.sender;
address to = address(this);
uint256 amount = 1e18;
_token.transferFrom(from, to, amount);
emit DoneStuff(from, to, amount);
}
}
Here, the contract imports the IERC20 which is just an interface. I'm trying to understand why the contract can execute this _token.transferFrom(from, to, amount);
without having the actual transferFrom function? Because the contract just imports the interface and does not have the transferFrom function implemented.
Could you help me clear my mind?