NFT Drop
When using the NFT Drop smart contract, additional top-level functionality is available to use.
To access the top-level functionality, use the get_nft_drop
method when creating the contract instance:
contract = python.get_nft_drop(
"{{contract_address}}",
)
The extensions that the NFT Drop contract supports are listed below.
- ERC721
- ERC721Burnable
- ERC721Supply
- ERC721LazyMintable
- ERC721Revealable
- ERC721ClaimPhases
- Royalty
- PlatformFee
- PrimarySale
- Permissions
- ContractMetadata
- Ownable
- Gasless
get_owned
Get the metadata of all NFTs a wallet owns from this contract.
# Address of the wallet to get the NFTs of
address = "{{wallet_address}}" # Optional - Defaults to the connected wallet
nfts = contract.erc721.get_owned(address)
Configuration
get_owned_token_ids
Get the token IDs owned by a specific address.
address = "0x..."
owned_nfts = contract.get_owned_token_ids(address)
Configuration
get_all_claimed
Get all claimed NFTs.
claimed_nfts = contract.get_all_claimed()
first_owner = claimed_nfts[0].owner
Configuration
query_params (optional)
Provide an optional QueryAllParams
object to configure the query. Useful for paginating the results.
class QueryAllParams:
start: int = 0
count: int = 100
from thirdweb.types.nft import QueryAllParams
query_params = QueryAllParams(
# The number of NFTs to return
count= 100, # Default is 100
# The index to start from
start= 0, # Default is 0
)
nfts = contract.get_all_claimed(query_params)
Return Value
List of NFTMetadataOwner
Objects
class NFTMetadataOwner:
metadata: NFTMetadata
owner: str
get_all_unclaimed
Get all unclaimed NFTs.
unclaimed_nfts = contract.get_all_unclaimed()
first_nft_name = unclaimed_nfts[0].name
Configuration
query_params (optional)
Provide an optional QueryAllParams
object to configure the query. Useful for paginating the results.
class QueryAllParams:
start: int = 0
count: int = 100
from thirdweb.types.nft import QueryAllParams
query_params = QueryAllParams(
# The number of NFTs to return
count= 100, # Default is 100
# The index to start from
start= 0, # Default is 0
)
nfts = contract.get_all_unclaimed(query_params)
Return Value
A list of unclaimed NFTMetadata
objects
class NFTMetadata:
id: int
uri: str
name: str
description: Optional[str] = None
image: Optional[str] = None
external_url: Optional[str] = None
animation_url: Optional[str] = None
background_color: Optional[str] = None
properties: Optional[Dict[Any, Any]] = None
attributes: Optional[Dict[str, Any]] = None
total_claimed_supply
Get the total number of NFTs claimed from this contract.
total_claimed = contract.total_claimed_supply()
Configuration
Return Value
An int
representing the number of NFTs claimed from this contract.
total_unclaimed_supply
Get the total number of unclaimed NFTs in this contract
total_unclaimed = contract.total_unclaimed_supply()
Configuration
Return Value
An int
representing the total number of unclaimed NFTs in this contract.
create_batch
Define a list of metadata objects that you want to lazy-mint.
from thirdweb.types.nft import NFTMetadataInput
# You can customize this metadata however you like
metadatas = [
NFTMetadataInput.from_json({
"name": "Cool NFT",
"description": "This is a cool NFT",
"image": open("path/to/file.jpg", "rb"),
}),
NFTMetadataInput.from_json({
"name": "Cooler NFT",
"description": "This is a cooler NFT",
"image": open("path/to/file.jpg", "rb"),
}),
]
txs = contract.create_batch(metadatas)
first_token_id = txs[0].id
first_nft = txs[0].data()
Configuration
A list of metadata objects for the NFTs you want to mint.
Must be a List
of NFTMetadataInput
object
s that conform to the metadata standards.
Alternatively, you can provide a list of string
s that point to valid metadata objects,
to override the default behavior of uploading and pinning the metadata to IPFS (shown below).
metadatas = [
NFTMetadataInput.from_json({
"name": "Cool NFT",
"description": "This is a cool NFT",
"image": open("path/to/file.jpg", "rb"),
}),
NFTMetadataInput.from_json({
"name": "Cooler NFT",
"description": "This is a cooler NFT",
"image": open("path/to/file.jpg", "rb"),
}),
]
txResult = contract.create_batch(metadatas)
class NFTMetadataInput:
name: str
description: Optional[str] = None
image: Optional[str] = None
external_url: Optional[str] = None
animation_url: Optional[str] = None
background_color: Optional[str] = None
properties: Optional[Dict[str, Any]] = None
attributes: Optional[Dict[str, Any]] = None
claim
Claim a specified number of tokens to the connected wallet.
quantity = 1
tx = contract.claim(quantity)
receipt = tx.receipt
claimed_token_id = tx.id
claimed_nft = tx.data()
Configuration
claim_to
The same as claim
, but allows specifying the recipient
address rather than using the connected wallet.
address = "0x7fDae677aA6f94Edff9872C4b91D26407709c790"
quantity = 1
tx = contract.claim_to(address, quantity)
receipt = tx.receipt
claimed_token_id = tx.id
claimed_nft = tx.data()