-1

Is there a way to do the following:

function registerCollection(address __collection) public {
        require(msg.sender == IERC721(__collection).owner), "Does not own contract");
        ...[rest of function]...
}

Is there a way, within solidity, to access the owner field of another contract. So I do not mean owns an NFT of another collection, which could be done by calling .ownerOf(tokenId) and comparing to msg.sender. I want to get the actual owner of the contract.

JUNIOR
  • 1
  • 1

1 Answers1

0

It's possible that a collection has a address public owner, especially if it inherits from Openzeppelin's Ownable library. So you are able to get it like this:

interface IOwnable {
  function owner() external view returns(address)
}

IOwnable(__collection).owner()

Though be aware that if a collection doesn't gave a public owner the call will revert.

0xSanson
  • 718
  • 1
  • 2
  • 11