I tried using interface to get the owner address from another NFT smart contract (ERC721) like this:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
interface INft {
function owner() external view returns (address); //doesn't work
function name() external view returns (string calldata); //works
function ownerOf(uint256 tokenId) external view returns (address); //works
}
contract Test {
//doesn't work
function getNftProjectOwner (address _nft) external view returns (address){
return INft(_nft).owner();
}
//works
function getNftProjectName (address _nft) external view returns (string memory){
return INft(_nft).name();
}
//works
function getNftTokenOwner(address _nft, uint256 _tokenId) external view returns (address){
return INft(_nft).ownerOf(_tokenId);
}
}
So far all other external function call works except for the one that gets the nft smart contract owner address. Here's the reference from OpenZeppelin's Ownable.sol:
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
I also noticed that Ownable is an abstract contract and I'm wondering if I have declared it as an interface wrongly? I kept getting the error message "call to Test.getNftProjectOwner errored: execution reverted"