Request form
Cookbook may introduce a token in the future. Share and contribute to be eligible for future airdrops.
close icon
relevant tag icon
Thirdweb NFT Collection
copy icon
thirdweb
• version 1.0.0
ERC721
NFT
Royalties
Audited

Thirdweb NFT Collection

Audited

The NFT Collection contract is suitable for when you want to have a collection of unique NFTs, but not "drop" or "release" them for your community to claim. Unlike the NFT Drop contract, the NFT Collection contract does not lazy mint your NFTs. Instead, NFTs are minted immediately when they are added to the collection. This means you can still transfer the NFTs or sell them on a Marketplace and perform any other actions you would expect to do with an NFT. For advanced use-cases, the NFT Collection also has signature-based minting capabilities.

*Visit desktop site to download or deploy

Version

1.0.0

Creator

thirdweb

Recent Use

🍞 0xcDA2 saved
🥐 0xcDA2 downloaded
🥖 0xd43B downloaded
🥨 0x08bF downloaded
🥯 0xc837 downloaded

Last Publish

10/23/2022
Any contract you deploy is yours.
Fully owned and controlled by your wallet.
Documentation
Source Code
initialize(address,string,string,string,address,address,uint128,uint128,address) :
This function is the initializer for the ERC721 token contract. It sets up the contract with the given parameters, including the name, symbol, contract URI, trusted forwarders, sale recipient, royalty recipient, royalty basis points, platform fee basis points, and platform fee recipient. It also sets up the default admin role, minter role, and transfer role, and assigns the default admin as the owner of the contract. Finally, it checks that the platform fee basis points does not exceed the maximum basis points. (autogenerated documentation)
contractType() :
This function returns a bytes32 value that represents the type of the contract. It does this by simply returning the value of the MODULE_TYPE constant, which is set when the contract is deployed. (autogenerated documentation)
contractVersion() :
This function returns the version of the contract. It does this by returning the value of the constant variable VERSION, which is declared outside of the function. (autogenerated documentation)
owner() :
This function returns the address of the owner of the contract. It does this by checking if the owner has the default admin role, and if so, returning the owner's address. If the owner does not have the default admin role, it returns a zero address. (autogenerated documentation)
verify() :
This function verifies a MintRequest and its associated signature. It does this by using the recoverAddress function to recover the address of the signer from the request and signature. It then checks if the request has not already been minted and if the signer has the MINTER_ROLE. If both of these conditions are met, it returns true and the address of the signer. (autogenerated documentation)
tokenURI(uint256) :
This function returns the URI associated with a given token ID. It works by taking in a uint256 _tokenId as an argument and then returning the corresponding URI from the uri mapping. (autogenerated documentation)
mintTo(address,string) :
This function is used to mint a new token to a specified address. It takes two parameters, an address and a string calldata. The address is the address of the recipient of the token, and the string calldata is a URI that contains information about the token. The function then calls the _mintTo() function, which is responsible for creating the token and transferring it to the specified address. (autogenerated documentation)
royaltyInfo(uint256,uint256) :
This function calculates the royalty amount for a given tokenId and salePrice. It does this by first retrieving the recipient address and royalty rate (in basis points) for the tokenId from the getRoyaltyInfoForToken function. It then calculates the royalty amount by multiplying the salePrice by the royalty rate and dividing it by the maximum basis points (MAX_BPS). The recipient address and royalty amount are then returned. (autogenerated documentation)
mintWithSignature() :
This function is used to mint a new token with a signature. It takes two parameters, a MintRequest struct and a signature, and returns a tokenIdMinted uint256. It first verifies the request and signature, then mints the token to the specified receiver address. If a royalty recipient is specified, it stores the royalty information in the royaltyInfoForToken mapping. Finally, it collects the price for the request and emits a TokensMintedWithSignature event. (autogenerated documentation)
setPrimarySaleRecipient(address) :
This function sets the primary sale recipient address for the contract. It can only be called by the default admin role, and it updates the primarySaleRecipient variable with the address passed in as an argument. It also emits an event to notify that the primary sale recipient has been updated. (autogenerated documentation)
setDefaultRoyaltyInfo(address,uint256) :
This function sets the default royalty recipient and royalty rate for the contract. It can only be called by the DEFAULT_ADMIN_ROLE, and requires that the royalty rate is less than or equal to the MAX_BPS. If these conditions are met, the royaltyRecipient and royaltyBps variables are set to the provided values, and an event is emitted to notify of the change. (autogenerated documentation)
setRoyaltyInfoForToken(uint256,address,uint256) :
This function sets the royalty information for a given token. It takes in three parameters: the token ID, the recipient address, and the royalty rate in basis points (bps). The function requires that the royalty rate is less than or equal to the maximum allowed royalty rate (MAX_BPS). If this requirement is met, the function stores the royalty information in the royaltyInfoForToken mapping. Finally, the function emits an event to signal that the royalty information has been set. (autogenerated documentation)
setPlatformFeeInfo(address,uint256) :
This function sets the platform fee recipient and the platform fee rate (in basis points) for the contract. It can only be called by the default admin role. The platform fee rate must be less than or equal to the maximum basis points (MAX_BPS) set in the contract. If the platform fee rate is successfully set, an event is emitted to notify the other contract participants. (autogenerated documentation)
setOwner(address) :
This function sets a new owner for the contract. It requires that the new owner has the DEFAULT_ADMIN_ROLE, and emits an event OwnerUpdated with the previous and new owner addresses. (autogenerated documentation)
setContractURI(string) :
This function sets the contractURI variable to the value of the _uri parameter. It can only be called by an account with the DEFAULT_ADMIN_ROLE. This allows the contract to store a URI that can be used to access additional information about the contract. (autogenerated documentation)
getPlatformFeeInfo() :
This function returns the address of the platform fee recipient and the platform fee rate (in basis points) for the contract. The platform fee rate is a percentage of the total amount of a transaction that is charged as a fee. The platform fee recipient is the address that will receive the fee. (autogenerated documentation)
getDefaultRoyaltyInfo() :
This function is used to retrieve the default royalty information for a particular contract. It returns a tuple containing the address of the royalty recipient and the royalty rate (in basis points). The royalty rate is a 16-bit unsigned integer, which is used to represent a percentage rate. The royalty rate is calculated by dividing the royalty rate by 10,000. (autogenerated documentation)
getRoyaltyInfoForToken(uint256) :
This function retrieves the royalty information for a given token ID. It takes in a uint256 _tokenId as an argument and returns a tuple containing the address of the royalty recipient and the royalty rate in basis points (bps). If the royalty recipient for the given token ID is not set, the function will return the default royalty recipient and royalty rate set in the contract. (autogenerated documentation)
_mintTo(address,string) :
This function is used to mint a new token to a given address. It takes in two parameters, an address to mint the token to and a string containing a URI. It then assigns the next available token ID to the token and stores the URI in the uri mapping. It then calls the _safeMint function to mint the token to the given address and emits an event to signal that the token has been minted. (autogenerated documentation)
recoverAddress() :
This function is used to recover the address of the signer of a given request. It does this by hashing the request data using the keccak256 algorithm, encoding the request data, and then using the recover() method of the hashTypedDataV4 function to recover the address of the signer from the provided signature. (autogenerated documentation)
_encodeRequest() :
This function encodes a MintRequest struct into a bytes memory array. The struct contains information about a request to mint a new NFT, such as the recipient, royalty recipient, royalty rate, primary sale recipient, URI, price, currency, validity start and end timestamps, and UID. The function encodes this data into a bytes memory array using the ABI encoding function. (autogenerated documentation)
verifyRequest() :
This function verifies a MintRequest, which is a request to mint a new token. It checks that the signature is valid, that the request is not expired, and that the recipient is defined. If all of these checks pass, it sets the minted status of the token to true and returns the address of the signer. (autogenerated documentation)
collectPrice() :
This function collects the price of a MintRequest and distributes it to the appropriate recipients. It first checks that the price is not zero, then calculates the platform fees based on the platformFeeBps. It then checks that the msg.value is equal to the totalPrice if the currency is the native token, and that the msg.value is zero if the currency is not the native token. Finally, it transfers the currency to the platformFeeRecipient and the primarySaleRecipient (or the _req.primarySaleRecipient if it is not address(0)). (autogenerated documentation)
burn(uint256) :
This function allows the owner or an approved address to burn a token with a given tokenId. It first checks that the caller is either the owner or an approved address for the tokenId. If the check passes, it calls the _burn() function to burn the token. (autogenerated documentation)
_beforeTokenTransfer(address,address,uint256) :
This function is an override of the _beforeTokenTransfer function from the ERC721EnumerableUpgradeable contract. It is used to restrict the transfer of tokens to holders of the TRANSFER_ROLE. It checks if the TRANSFER_ROLE has been granted to the sender or the recipient of the token transfer, and if not, it will throw an error. If the transfer is from or to address 0, then the check is skipped. (autogenerated documentation)
supportsInterface(bytes4) :
This function is used to check if a contract supports a given interface. It takes a bytes4 interfaceId as an argument and returns a boolean value indicating whether the contract supports the interface or not. The function first checks if the interface is supported by the parent contract using the super.supportsInterface() function. If not, it then checks if the interfaceId matches the type of IERC2981Upgradeable. If either of these checks returns true, the function returns true, otherwise it returns false. (autogenerated documentation)
_msgSender() :
This function is used to retrieve the address of the sender of the current message. It works by calling the _msgSender() function from the ERC2771ContextUpgradeable contract, which returns the address of the sender. (autogenerated documentation)
_msgData() :
This function is used to retrieve the data associated with a given message call. It works by calling the _msgData() function from the ERC2771ContextUpgradeable contract, which returns the data associated with the message call as a byte array. (autogenerated documentation)

Get Cookin'
share iconShare

copy iconDownload Source
copy iconnpx cookbookdev i thirdweb-nft-collection
copy icon

Recent Use

🍞 0xcDA2 saved
🥐 0xcDA2 downloaded
🥖 0xd43B downloaded
🥨 0x08bF downloaded
🥯 0xc837 downloaded

Last Publish

10/23/2022

Version

1.0.0

Creator

thirdweb

Cookbook is free.
Any contract you deploy is yours.
Your contract is owned and controlled by you.