Skip to main content

contracts.nft_drop

NFTDrop Objects

class NFTDrop(ERC721[DropERC721])

Setup a collection of one-of-one NFTs that are minted as users claim them.

from thirdweb import ThirdwebSDK

# You can customize this to a supported network or your own RPC URL
network = "mumbai"

# Now we can create a new instance of the SDK
sdk = ThirdwebSDK(network)

# If you want to send transactions, you can instantiate the SDK with a private key instead:
# sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, network)

contract = sdk.get_nft_drop("{{contract_address}}")

get_owned

def get_owned(address: str = "") -> List[NFTMetadataOwner]

Get the metadata of all tokens owned by a specific address

nfts = contract.get_owned("{{wallet_address}}")
print(nfts)

Arguments:

  • address: the address to get the metadata for

Returns:

the metadata of all tokens owned by the address

get_owned_token_ids

def get_owned_token_ids(address: str = "") -> List[int]

Get the token IDs owned by a specific address

Arguments:

  • address: the address to get the token IDs for

Returns:

the token IDs owned by the address

get_all_claimed

def get_all_claimed(query_params: QueryAllParams = QueryAllParams()
) -> List[NFTMetadataOwner]

Get all claimed NFTs.

claimed_nfts = contract.get_all_claimed()
first_owner = claimed_nfts[0].owner

Arguments:

  • query_params: Query parameters.

Returns:

List of nft metadatas and owners for claimed nfts.

get_all_unclaimed

def get_all_unclaimed(query_params: QueryAllParams = QueryAllParams()
) -> List[NFTMetadata]

Get all unclaimed NFTs.

unclaimed_nfts = contract.get_all_unclaimed()
first_nft_name = unclaimed_nfts[0].name

Arguments:

  • query_params: Query parameters.

Returns:

List of nft metadatas.

total_claimed_supply

def total_claimed_supply() -> int

Get the total number of NFTs claimed from this contract

total_claimed = contract.total_claimed_supply()

Returns:

Total number of NFTs claimed from this contract

total_unclaimed_supply

def total_unclaimed_supply() -> int

Get the total number of unclaimed NFTs in this contract

total_unclaimed = contract.total_unclaimed_supply()

Returns:

Total number of unclaimed NFTs in this contract

create_batch

def create_batch(
metadatas: List[NFTMetadataInput]
) -> List[TxResultWithId[NFTMetadata]]

Create a batch of NFTs.

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()

Arguments:

  • metadatas: List of NFT metadata inputs.

Returns:

List of tx results with ids for created NFTs.

claim_to

def claim_to(
destination_address: str,
quantity: int,
proofs: List[str] = [DEFAULT_MERKLE_ROOT]
) -> List[TxResultWithId[NFTMetadata]]

Claim NFTs to a destination address.

address = {{wallet_address}}
quantity = 1

tx = contract.claim_to(address, quantity)
receipt = tx.receipt
claimed_token_id = tx.id
claimed_nft = tx.data()

Arguments:

  • destination_address: Destination address to claim to.
  • quantity: Number of NFTs to claim.
  • proofs: List of merkle proofs.

Returns:

List of tx results with ids for claimed NFTs.

claim

def claim(
quantity: int,
proofs: List[str] = [DEFAULT_MERKLE_ROOT]
) -> List[TxResultWithId[NFTMetadata]]

Claim NFTs.

Arguments:

  • quantity: Number of NFTs to claim.
  • proofs: List of merkle proofs.

Returns:

List of tx results with ids for claimed NFTs.