Brownie: Create and Mint an NFT Using Brownie
Learn how to create and mint an NFT using Brownie.
Last updated
Was this helpful?
Learn how to create and mint an NFT using Brownie.
Last updated
Was this helpful?
Brownie is a smart contract web3 development framework built from the Python library . Brownie has a variety of template projects for users to get started with and develop their own projects. These templates are referred to as ‘Brownie mixes’. In this tutorial, we’ll use a Brownie mix for creating an ERC721 NFT token. This mix comes with some sample assets and metadata files, but we’ll upload our own assets to Filebase and create personalized metadata files to create our NFTs.
Read below to learn how to create and mint an NFT using Brownie.
To do this, navigate to . If you don’t have an account already, , then log in.
Select ‘Create Bucket’ in the top right corner to create a new bucket for your NFTs.
Bucket names must be unique across all Filebase users, be between 3 and 63 characters long, and can contain only lowercase characters, numbers, and dashes.
Once uploaded, it will be listed in the bucket.
Choose the method you prefer, and take note of the IPFS CID for your image. We will reference this later.
.json
file that correlates with your NFT image.This can be named anything you’d like, but ideally should correlate to whichever NFT it belongs with. For example, if you name your NFTs according to their number in the collection, the .json
file for NFT #1 should be 1.json
.
This file will hold the metadata for your NFT, such as its name, description, and any attributes. The format of this file is as follows:
Replace the name, description, and attributes with any values you want. Then replace the FILEBASE_IPFS_CID
value with the IPFS CID you took note of in Step 6.
.json
file to your Filebase IPFS bucket using the same workflow we used to upload our image files.Take note of the IPFS CID for your .json
file.
Use the following commands to download the Brownie Mix for creating NFTs:
git clone https://github.com/PatrickAlphaC/nft-mix
cd nft-mix
eth-brownie
package and ganache-cli
:pip install eth-brownie
npm install -g ganache-cli
.env
file in your project directory.Replace the existing content with the following:
export PRIVATE_KEY=WALLET_PRIVATE_KEY
export WEB3_INFURA_PROJECT_ID=INFURA_PROJECT_ID
Replace the values WALLET_PRIVATE_KEY
with your cryptowallet’s private key, and INFURA_PROJECT_ID
with your Infura Project ID.
Save the file.
This Brownie Mix uses the OpenZepplin package for the ERC721 token. Use the following command to deploy the contract:
brownie run scripts/simple_collectible/deploy_simple.py --network rinkeby
scripts/simple_collectible/create_collectible.py
.This is the script that creates our NFT. We’ll need to edit this file to use the IPFS image we uploaded to Filebase. Replace the following line in this script:
sample_token_uri = "ipfs://FILEBASE_IPFS_CID”
Replace FILEBASE_IPFS_CID
with the IPFS CID of your NFT image from the beginning of this tutorial.
Run the script with the following command:
brownie run scripts/simple_collectible/create_collectible.py --network rinkeby
You’ve now minted your first NFT on the Ethereum testnet! From here, you can upload more image files and json files, then change your script to reflect the IPFS CID for each one to upload as many NFTs as you’d like!
If you are using Metamask, follow the instructions found .