Skip to content
Available on private testnetTestnet: yesMainnet: Not availableSoftware: Core bad4a06ea · protocol pqwerai-v8-testnet/1Updated

ERC-721 NFTs

Unique tokens follow ERC-721. Tested in Create NFTs.

PQCollection.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

/// Example ERC-721 collection: the owner mints sequential IDs; metadata lives at baseURI + tokenId.
/// Unaudited tutorial code.
contract PQCollection is ERC721, Ownable {
    uint256 public nextId = 1;
    string private base;

    constructor(string memory baseURI_, address owner_) ERC721("Tutorial Collection", "TCOL") Ownable(owner_) {
        base = baseURI_;
    }

    function mint(address to) external onlyOwner returns (uint256 id) {
        id = nextId++;
        _safeMint(to, id);
    }

    function _baseURI() internal view override returns (string memory) {
        return base;
    }
}
  • tokenURI(id) returns baseURI + id; host JSON metadata on IPFS or HTTPS. The chain stores only the URI.
  • _safeMint/safeTransferFrom revert with ERC721InvalidReceiver if a receiving contract lacks onERC721Received.
  • Transfer(from, to, tokenId) has tokenId indexed; the explorer uses this to index NFT transfers.
  • The Windows Wallet lists ERC-721 tokens it discovers and transfers them; its Studio NFT collection template deploys an equivalent OpenZeppelin collection without code.

Found a problem? Report a documentation issue · Build testnet-rc1+72057fe3ec