Sometimes you just want to know if someone owns an NFT regardless of the chain, regardless of the ERC- standard. This protocol was made just for this. I got sick of making edge cases for every single contracts and every single standards. So the idea behind this network of contracts and this API is to obtain the owner of an NFT in one single call.
Documentation and repo is available at https://api.ownerof.xyz/
Find the list of addresses here
///@dev Interface of OwnershipChecker;
interface IOwnershipChecker{
function ownerOfTokenAt(address _impl,uint256 _tokenId,address _potentialOwner) external view returns (address);
}
contract MyContract{
address checker;
constructor(address _checker){
_checker = checker;
}
function getOwnerOfToken_NotERC1155(address myOtherTokenAddress, uint256 myToken) public view returns(address){
// In this case we assume we know for a fact the myOtherTokenAddress is not an ERC1155.
address result = IOwnershipChecker(checker).ownerOfTokenAt(myOtherTokenAddress,myToken,address(0))
return result
}
function getOwnerOfToken(address myOtherTokenAddress, uint256 myToken,address potentialOwner) public view returns(address){
address result = IOwnershipChecker(checker).ownerOfTokenAt(myOtherTokenAddress,myToken,potentialOwner)
return result
}
}
Noawadays, we thankfully have ethereum standards. For example EIP721, EIP1155 and more.
These, on top of EIP165 make checking the standard of a given smart contract easier.
However, this completely ignores previous NFT projects that were born prior to 2018 (for example Cryptokitties).
This means that now, to know who owns a given NFT, one has to check for the standard of a smart contract, and then has to call different functions depending on those standards IF that contract supports the ERC721 interface or the ERC1155 interface.
If the contract doesn't support those, a manual process begins where the front-end has to iterate through some specific interfaces and call non-standard methods.
All of that to know who owns a given NFT.
Goal: Know the owner of an NFT in one single call.
https://github.com/Benjythebee/OwnershipChecker/blob/master/solidity/readme.md
To add a supported contract, create an issue or a pull request!
List of currently supported chains:
- Polygon
- Ethereum
- any ERC1155
- any ERC721
Todo:
- More contracts to be supported
- create ownerOf for ERC20;
-
Clone the repo
-
Make a branch and make changes;
-
Make a pull request.