NFTPort is a simple and developer-friendly NFT API and infrastructure that allows developers to create and deploy their NFT applications or collections in just a few hours instead of requiring months of development. NFTPort manages the backend NFT infrastructure and provides a versatile API for interacting with the infrastructure.
Read below to learn how to mint an NFT collection with NFTPort.
Prerequisites:
1. First, we need to upload some NFT image files to IPFS through Filebase.
We’ll start by uploading 3 images to Filebase for us to use. To do this, navigate to console.filebase.com. If you don’t have an account already, sign up, then log in.
Select ‘Create Bucket’ in the top right corner to create a new bucket for your NFTs.
3. Enter a bucket name and choose the IPFS storage network to create the bucket.
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.
4. Next, select the bucket from your list of buckets, then select ‘Upload’ in the top right corner to upload your image files.
5. Select your images to be uploaded.
Once uploaded, they will be listed in the bucket.
6. You can view the object’s IPFS CID in the CID column, or you can click on your uploaded object to display the metadata for the object, which includes the IPFS CID.
Choose the method you prefer, and take note of the IPFS CID.
7. Next, create a new project folder for our project files. We’ll call it nft-collection. Then navigate inside this new folder.
mkdir nft-collection
cd nft-collection
8. Inside this folder, create another folder for your NFTs’ metadata files.
Call this ‘metadata’, then navigate inside of it as well.
mkdir metadata
cd metadata
9. Next, create a .JSON file for each NFT you plan to create in your collection. The format for this JSON file is as follows:
{"name":"NFT #1","description":"The first NFT in my collection","image":"https://ipfs.filebase.io/ipfs/IPFS_FILEBASE_CID","attributes": [ {"trait_type":"Rarity","value":"Average" } ]}
Replace IPFS_FILEBASE_CID with the CID for each NFT image you uploaded to Filebase.
To simplify things, name each .JSON file in the same manner you named your NFT image files. For example, if you followed a numerical naming scheme such as 1.png, 2.png, name your .JSON files as 1.JSON, 2.JSON, etc. Save all of these files in the ‘metadata’ directory.
10. Sign up for a free NFTPort API key here. We’ll need this in the next step.
11. Navigate back to the root directory of the project. Create a new file called upload.py.
Enter the following code into this file:
import requestsimport osfrom os import listdirfrom os.path import joinmetadata_directory_path =./metadata" files = [f for f inlistdir(metadata_directory_path)ifstr(join(metadata_directory_path, f)).endswith('.json')]metadata_files = []for metadata in files: metadata_files.append( ("metadata_files", open(os.path.join(metadata_directory_path, metadata), "rb")))response = requests.post("https://api.nftport.xyz/v0/metadata/directory", headers={"Authorization": "NFTPORT_API_KEY"}, files=metadata_files )print(response.json())
Replace the following values:
NFTPORT_API_KEY: Your NFTPort API key from step 10.
12. Deploy the contract with the following curl command: