Quai Network Logo

NFT Deployer

Easily deploy an NFT collection on Quai Network.

Enter the name of your collection.

Enter your collection symbol.

Metadata Extension

Enter the file extension type for your metadata.

Metadata URI

Enter the CID for your collection's metadata ".json" files.

Set the size of your collection.

The ERC721 Contract

The Quai NFT deployer is configured to deploy the base implementation of Open Zeppelin's ERC721 standard expanded with the URI-Storage extension and Ownable modifier contract. Deploying the contract will create a new NFT collection with the specified name, symbol, metadata, and collection size. You as the owner will be able to mint new NFTs and transfer ownership of the collection.

While the contract contract below is useful for simple deployments, it lacks customizability. If your NFT collection requires more advanced features such as custom minting or complex metadata, consider writing your own contract and deploying it via Hardhat.

erc721.sol

1
// SPDX-License-Identifier: MIT
2
pragma solidity ^0.8.20;
3
4
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
5
import "@openzeppelin/contracts/access/Ownable.sol";
6
import "@openzeppelin/contracts/utils/Strings.sol";
7
8
contract TestERC721 is ERC721URIStorage, Ownable {
9
using Strings for uint256;
10
string private baseTokenURI;
11
uint256 private mintedTokens;
12
uint256 private maxTokens;
13
14
/**
15
* @dev Constructor sets msg.sender as contract owner.
16
* @dev Sets the base token URI.
17
*
18
* @param name Name of the token.
19
* @param symbol Symbol of the token.
20
* @param baseTokenURI_ Base token URI.
21
*/
22
constructor(string memory name, string memory symbol, string memory baseTokenURI_, uint256 maxTokens_) ERC721(name, symbol) Ownable(msg.sender) {
23
baseTokenURI = baseTokenURI_;
24
mintedTokens = 0;
25
maxTokens = maxTokens_;
26
}
27
28
/**
29
* @dev Mints tokens to the specified address.
30
* @dev Modifier onlyOwner restricts the minting function to the contract owner.
31
* @dev Restricts the number of tokens that can be minted to 1000.
32
*
33
* @param to Address to which tokens are to be minted.
34
*/
35
function mint(address to) public onlyOwner {
36
require(mintedTokens < maxTokens, "All tokens have been minted");
37
_safeMint(to, mintedTokens);
38
mintedTokens++;
39
}
40
41
/**
42
* @dev Override required by ERC721URIStorage to return the token URI.
43
* Adds ".json" to the end of the token ID to match the expected format of the tokenURI.
44
* Reverts if token does not exist.
45
*
46
* @param tokenId The token ID to return the URI for.
47
*/
48
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
49
require(tokenId <= maxTokens, "Token ID out of range.");
50
require(ownerOf(tokenId) != address(0), "Nonexistent token.");
51
string memory baseURI = _baseURI();
52
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), ".json")) : "";
53
}
54
55
/**
56
* @dev Returns the base token URI.
57
*/
58
function _baseURI() internal view virtual override returns (string memory) {
59
return baseTokenURI;
60
}
61
62
/**
63
* @dev Returns the collection size.
64
*/
65
function _maxTokens() public view returns (uint256) {
66
return maxTokens;
67
}
68
}