Mint an NFT Collection with Python

Mint an NFT Collection with Python

In this guide, you'll learn how to mint your own NFT using Python! We'll be using the thirdweb dashboard and python SDK to complete this project.

Dashboard setup

The first thing we'll need to do is head to the thirdweb dashboard.

You'll need to connect your wallet, so if you don't have a one, check out our guide on how to Create a MetaMask wallet.

Click "Deploy new contract" in the top right corner, then "Deploy Now" on the NFT Collection contract.

Set up your NFT Collection with some metadata, including image, name, description, and royalty settings.

Create a Python file

Go ahead and create a new Python file. Let's call it and open it in your favorite code editor. We'll use Visual Studio.

Next up, use the following code in your terminal to install the SDK!

# thirdweb-sdk
pip install thirdweb-sdk

Setup the SDK

Now that we have our environment setup with the thirdweb python SDK, we can get started. In our file, we can use the following code:

from thirdweb import ThirdwebSDK
from thirdweb.types.nft import NFTMetadataInput

# Learn more about securely accessing your private key:
PRIVATE_KEY = "<your-private-key-here>"

# Set the network you want to operate on, or add your own RPC URL here
NETWORK = "mumbai"

# Finally, you can create a new instance of the SDK to use
sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, NETWORK)

Ensure you store and access your private key securely.

  • Never commit any file that may contain your private key to your source control.

Learn more about securely accessing your private key.

Define the NFT Collection contract

Now that we have an SDK instance setup, we can get the interface for our NFT Collection!

Our NFT Collection that we deployed from the dashboard has its own unique address that can be used to identify it,
which can be found next to your contract name on the thirdweb dashboard.

We can now use this address to use our NFT Collection with the SDK with the following code:

# Instantiate a new NFT Collection contract as described above.
nft_collection = sdk.get_nft_collection(NFT_COLLECTION_ADDRESS)

Time to mint the NFT!

Now we can mint a new NFT with the sdk!
The arguments passed over here are the same as minting an NFT inside the dashboard. If you want to familiarize yourself with the process, check out the dashboard!

# Now you can use any of the SDK contract functions including write functions{
    "name": "Cool NFT",
    "description": "Minted with the Python SDK!",
    "image": "ipfs://QmdFeKxt6FJUNvaGgzYuYNRbpNWyHxP2PFzjsgPf1eD2Jf"


Get the balance to check it out or head over to the dashboard.

# check your balance to check if you minted an nft!

So the only thing left is to run our code! Open a terminal and paste the following:


That's it!

You have minted your own NFT using thirdweb and the Python SDK, you should be proud!