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 Drop
copy icon
thirdweb
• version 1.0.0
ERC721
NFT
Royalty
Audited

Thirdweb NFT Drop

Audited

The NFT Drop contract is ideal when you want to release a collection of unique NFTs using the ERC721 Standard. It allows you to define a set of conditions called claim phases in a sequence which defines when and how your users can claim an NFT from your drop; including allowlists, release dates, claim limits, and delayed reveals. When you add NFTs to your drop contract, they are not minted at this point. You prepare everything for your users by lazy minting them, so that other wallets can mint them

*Visit desktop site to download or deploy

Version

1.0.0

Creator

thirdweb

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 contract. It sets up the contract with the given parameters, including the default admin, 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 roles of default admin, minter, and transfer role, and assigns the default admin to these roles. Finally, it sets the owner of the contract to the default admin. (autogenerated documentation)
contractType() :
This function is an external pure function that returns a bytes32 value. It is used to return the type of the contract, which is stored in the MODULE_TYPE constant. This allows users to easily identify the type of contract they are interacting with. (autogenerated documentation)
contractVersion() :
This function is a getter function that returns the version of the contract. It is a pure function, meaning that it does not modify the state of the contract and does not interact with the blockchain. It simply returns the value of the constant variable VERSION, which is a uint8 (unsigned 8-bit integer) that stores the version of the contract. (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)
tokenURI(uint256) :
This function is used to generate a unique URI for a given token ID. It iterates through an array of baseURIIndices and checks if the given token ID is less than the current index. If it is, it checks if the encryptedData at that index is empty. If it is, it returns a string containing the baseURI and the token ID. If it is not empty, it returns a string containing the baseURI and a 0. (autogenerated documentation)
supportsInterface(bytes4) :
This function is used to check if a contract supports a given interface. It takes in 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 interface is the IERC2981Upgradeable interface using the type() function. If either of these checks returns true, the function returns true, otherwise it returns false. (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)
lazyMint(uint256,string) :
This function is used to mint a batch of tokens with a given base URI and optional data. It takes in an amount of tokens to mint, a base URI for the tokens, and optional data as parameters. The function then sets the next token ID to mint to the base URI index, stores the base URI in the baseURI mapping, and pushes the base URI index to the baseURIIndices array. If the data parameter is not empty, the function will decode the data and store the encrypted URI and provenance hash in the encryptedData mapping. Finally, the function emits an event to indicate that the tokens have been lazily minted. (autogenerated documentation)
reveal(uint256) :
This function allows the minter role to reveal the baseURI of an NFT. It takes an index and a key as parameters. It first checks that the index is valid, then it decodes the encrypted data stored at the given index. It then uses the key to decrypt the encryptedURI and stores the revealedURI in the baseURI mapping. Finally, it emits an event and returns the revealedURI. (autogenerated documentation)
encryptDecrypt() :
This function is an encryption/decryption function that takes in a byte array of data and a byte array of a key as parameters. It uses the keccak256 hashing algorithm to encrypt/decrypt the data. The function iterates through the data byte array, 32 bytes at a time, and uses the key and the current iteration number to generate a hash. This hash is then used to XOR the current 32 bytes of data, and the result is stored in the result byte array. The result byte array is then returned. (autogenerated documentation)
claim(address,uint256,address,uint256,bytes32[],uint256) :
This function allows a user to claim tokens from a specific condition. It requires the user to provide a valid Merkle proof, the quantity of tokens to be claimed, the currency to be used for payment, the price per token, and the maximum quantity of tokens that can be claimed per transaction. The function then verifies the Merkle proof and the claim, collects the payment, and transfers the claimed tokens to the specified receiver. Finally, it emits an event to notify that the tokens have been claimed. (autogenerated documentation)
setClaimConditions(bool) :
This function is used to set the claim conditions for a given contract. It takes an array of ClaimCondition objects and a boolean value as parameters. The function first checks if the resetClaimEligibility boolean is set to true, and if so, sets the newStartIndex to the existingStartIndex plus the existingPhaseCount. It then iterates through the array of ClaimCondition objects, checking that the startTimestamp of each phase is greater than the last. It also checks that the supplyClaimed is less than or equal to the maxClaimableSupply. If the resetClaimEligibility boolean is set to true, the function deletes the claimCondition.phases and claimCondition.limitMerkleProofClaim for (autogenerated documentation)
collectClaimPrice(uint256,address,uint256) :
This function collects the claim price for a given quantity of tokens. It takes three parameters: the quantity of tokens to claim, the currency of the tokens, and the price per token. It then calculates the total price by multiplying the quantity by the price per token. It then calculates the platform fees by multiplying the total price by the platform fee BPS and dividing it by the maximum BPS. If the currency is the native token, it requires that the message sender sends the total price. Finally, it transfers the platform fees to the platform fee recipient and the total price minus the platform fees to the primary sale recipient. (autogenerated documentation)
transferClaimedTokens(address,uint256,uint256) :
This function is used to transfer tokens that have been claimed by a user. It takes in three parameters: the address of the recipient, the ID of the condition that the tokens are being claimed under, and the quantity of tokens being claimed. It then updates the supplyClaimed value of the condition, the limitLastClaimTimestamp of the condition for the sender, and the walletClaimCount of the sender. It then uses a for loop to mint the tokens to the recipient, incrementing the tokenIdToClaim each time. Finally, it updates the nextTokenIdToClaim value. (autogenerated documentation)
verifyClaim(uint256,address,uint256,address,uint256,bool) :
This function is used to verify a claim made by a user. It checks that the currency and price per token are valid, that the quantity is greater than 0 and not exceeding the maximum quantity per transaction, that the total supply claimed is not exceeding the maximum claimable supply, that there are enough minted tokens to cover the claim, that the total supply is not exceeding the maximum total supply, and that the user has not exceeded their claim limit. It also checks that the user has waited the required amount of time since their last claim. (autogenerated documentation)
verifyClaimMerkleProof(uint256,address,uint256,bytes32[],uint256) :
This function verifies a Merkle proof for a claim condition. It takes in the condition ID, the claimant's address, the quantity of the claim, an array of proofs, and the maximum quantity per transaction. It then checks that the Merkle root of the claim condition matches the proofs, that the claimant has not already claimed the proof, and that the quantity of the claim is less than or equal to the maximum quantity per transaction. If all of these checks pass, the function returns true and the index of the proof in the array. (autogenerated documentation)
s function getActiveClaimConditionId() :
This function returns the ID of the active claim condition. It does this by looping through the claimCondition.phases array, starting from the currentStartId + count and decrementing until it finds a phase whose startTimestamp is less than or equal to the current block timestamp. If no such phase is found, the function reverts. (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)
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)
getClaimTimestamp(uint256,address) :
This function retrieves the timestamp of the last claim made by a particular address for a given condition ID, as well as the timestamp of the next valid claim. It does this by accessing the limitLastClaimTimestamp mapping, which stores the last claim timestamp for each condition ID and address. The waitTimeInSecondsBetweenClaims is then added to the last claim timestamp to calculate the next valid claim timestamp. If the addition of the two timestamps results in an overflow, the next valid claim timestamp is set to the maximum value of a uint256. (autogenerated documentation)
getClaimConditionById(uint256) :
This function retrieves a ClaimCondition from the contract's storage based on the provided conditionId. It does this by accessing the "phases" mapping in the claimCondition struct and returning the ClaimCondition associated with the provided conditionId. (autogenerated documentation)
getBaseURICount() :
This function returns the number of base URIs stored in the contract. It does this by accessing the length of the baseURIIndices array, which stores the indices of the base URIs. (autogenerated documentation)
s function setWalletClaimCount(address,uint256) :
This function sets the wallet claim count for a given address. It takes two parameters, an address and a uint256, and stores the uint256 in a mapping with the address as the key. It also emits an event, WalletClaimCountUpdated, with the address and the uint256 as parameters. This function can only be called by the DEFAULT_ADMIN_ROLE. (autogenerated documentation)
setMaxWalletClaimCount(uint256) :
This function sets the maximum number of wallet claims that can be made by a user. It is only accessible to the DEFAULT_ADMIN_ROLE, which is a role that is assigned to a specific user or group of users. When the function is called, the maxWalletClaimCount variable is set to the value of the _count parameter, and an event is emitted to notify other users that the value has been updated. (autogenerated documentation)
setMaxTotalSupply(uint256) :
This function sets the maximum total supply of a token. It is only accessible to the default admin role, and it emits an event when the maximum total supply is updated. The function takes in a uint256 parameter, which is the new maximum total supply. (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 all future purchases of the token. It requires the address of the royalty recipient and the royalty rate (in basis points) as parameters. The function also checks that the royalty rate is not greater than the maximum allowed basis points. If the parameters are valid, the function sets the royalty recipient and rate and emits an event to notify 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 bps (basis points). The function requires that the bps is less than or equal to the maximum bps, and then sets the royalty information for the token in the royaltyInfoForToken mapping. Finally, it emits an event with the token ID, recipient address, and bps. (autogenerated documentation)
setPlatformFeeInfo(address,uint256) :
This function sets the platform fee recipient and platform fee bps (basis points) for the contract. It requires that the platform fee bps is less than or equal to the maximum bps (MAX_BPS) and sets the platform fee bps to a uint16. It then sets the platform fee recipient to the address passed in and emits an event to notify that the platform fee info has been updated. (autogenerated documentation)
setOwner(address) :
This function allows the owner of the contract to change the owner of the contract. It requires that the new owner has the DEFAULT_ADMIN_ROLE, and if they do, the _owner variable is updated to the new owner's address. An OwnerUpdated event is then emitted, containing the previous owner's address and the new owner's address. (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)
burn(uint256) :
This function allows the owner or an approved address to burn a token with the given tokenId. It first checks that the caller is either the owner or an approved address of the token, and then 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 check if the sender and receiver of a token transfer have the TRANSFER_ROLE permission. If the sender and receiver do not have the TRANSFER_ROLE permission, the transfer is not allowed. This function also allows the transfer of tokens from address(0) to any other address without requiring the TRANSFER_ROLE permission. (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-drop
copy icon

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.