IERC721 function call / inheritance


I have a couple of questions, to understand better this issue.
I found a smart contract in which I saw the following line of code:

IERC721(nftContract).transferFrom(msg.sender, address(this), tokenId);
  1. IERC721 is an interface, and all the functions are not implemented...
  2. The contract inheritance is ReentrancyGuard.sol, which is an abstract contract and do not inherit either ERC721 or IERC721.

Could some one explain how this works?



:1234: Code to reproduce

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import '@openzeppelin/contracts/token/ERC721/ERC721.sol';
import '@openzeppelin/contracts/security/ReentrancyGuard.sol';
import '@openzeppelin/contracts/utils/Counters.sol';
import 'hardhat/console.sol';

contract MyMkt is ReentrancyGuard {
	function mktPlace (address nftContract, uint256 tokenId) public payable nonReentrant{ 
		IERC721(nftContract).transferFrom(msg.sender, address(this), tokenId);


Interfaces are not supposed to implement anything. Interfaces is what the name implies, an interface definition

wrapping an address with an interface InterfaceABC(addr) means "treat this address as this type of contract"

i suggest reading some of the examples on the Solidity's documentation and some examples.

Thanks for your answer