Interactive DemoDeploy NFT pragma solidity ^0.8.20; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; /** * @title EnumerableNFT * @dev Implementation of an enumerable ERC721 NFT token */ contract EnumerableNFT is ERC721Enumerable { using Counters for Counters.Counter; Counters.Counter private _tokenIds; // Events event Minted(address indexed to, uint256 indexed tokenId); constructor( string memory name, string memory symbol ) ERC721(name, symbol) {} /** * @dev Mint a new token */ function mint() public returns (uint256) { _tokenIds.increment(); uint256 newTokenId = _tokenIds.current(); _safeMint(msg.sender, newTokenId); emit Minted(msg.sender, newTokenId); return newTokenId; } /** * @dev Get all token IDs owned by an address */ function tokensOfOwner(address owner) public view returns (uint256[] memory) { uint256 tokenCount = balanceOf(owner); uint256[] memory tokens = new uint256[](tokenCount); for(uint256 i = 0; i < tokenCount; i++) { tokens[i] = tokenOfOwnerByIndex(owner, i); } return tokens; } }PreviousInteractive DemosNextRPCs