Question : get all owners who has token in solidity
Answered by : dejan-ilic
function getOwners() public view onlyOwner returns (address[] memory){ uint256 total = totalSupply(); address[] memory owners = new address[](total); for(uint256 tokenId = 0; tokenId < total; tokenId ++) { require(_exists(tokenId), "Token does not exist"); owners[tokenId] = ownerOf(tokenId); } return owners; }
Source : | Last Update : Tue, 28 Jun 22