Created
August 17, 2021 23:49
-
-
Save saadSarwar28/c149e783f086d99d572a7750e05a6e40 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.4+commit.c7e474f2.js&optimize=false&runs=200&gist=
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.7.0 <0.9.0; | |
/** | |
* @title Ownership | |
* check Ownership of nfts | |
*/ | |
interface deployedContract { | |
function totalSupply() external view returns (uint); | |
function ownerOf(uint tokenId)external view returns (address); | |
} | |
contract Storage { | |
function checkOwnership(address walletAddress, address contractAddress) public returns (uint[] memory){ | |
// getting total supply of the contract | |
uint256 totalSupply = getTotalSupply(contractAddress); | |
// initializing an array with the size of the total supply because total supply would be the maximum of it. | |
uint[] memory ids = new uint[](totalSupply); | |
// for contracts whose owner is the given address. | |
for (uint id = 0; id < totalSupply; totalSupply++) { | |
if (walletAddress == deployedContract(contractAddress).ownerOf(id)) { | |
ids[id] = id; | |
} | |
} | |
return ids; | |
} | |
function getTotalSupply(address contractAddress) internal returns(uint256) { | |
return deployedContract(contractAddress).totalSupply(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment