This is an example of how I mint a NFT collection in Python
import os
import json
import time
from dotenv import load_dotenv
from iota_wallet import IotaWallet
import random
load_dotenv()
shimmer_mnemonic = os.getenv("SHIMMER_MNEMONIC")
stronghold_password = os.getenv("STRONGHOLD_PASSWORD")
wallet_db_name = os.getenv("WALLET_DB_NAME")
shimmer_account_name = os.getenv("SHIMMER_ACCOUNT_NAME")
stronghold_db_name = os.getenv("STRONGHOLD_DB_NAME")
# In this example we will mint an nft
client_options = {
'nodes': ['https://api.testnet.shimmer.network'],
}
wallet = IotaWallet(wallet_db_name, client_options)
account = wallet.get_account(shimmer_account_name)
# Sync account with the node
response = account.sync()
print(f'Synced: {response}')
wallet.set_stronghold_password(stronghold_password)
nft_collection_size = 30 # 10 NFTs in the collection
issuer_nft_id = "rms1zpzck5vsgzlc8snf3w20z852sntyq3uxed80l46afnsj5zulms3fu4837s2"
# Create the metadata with another index for each
nft_options = []
for index in range(nft_collection_size):
nft_number = index + 1
attribue_value = random.randint(42, 69)
immutable_metadata = bytes(json.dumps({
"standard": "IRC27",
"version": "v1.0",
"type": "image/png",
"uri": "ipfs://bafybeicnznoiprv5udy36wlrhqffa7evyaodewea343dnavgt3aqn4gwbm",
"name": f"Mudskipper #{nft_number}",
"description": "The Mudskipper",
"issuerName": "The Queen",
"collectionName": "The 30y old virgin collection",
"attributes": [
{
"trait_type": "Rarity",
"value": f"{attribue_value}"
}
]
}).encode('utf-8')).hex()
print(f"immutableMetadata: {immutable_metadata}")
combined_metadata = "0x" + immutable_metadata
nft_options.append({
"immutableMetadata": combined_metadata,
"issuer": issuer_nft_id,
})
print(f'NFT Options: {nft_options}')
for nfts in [nft_options[i:i+50] for i in range(0, len(nft_options), 50)]:
transaction = account.mint_nfts(nft_options)
print(f'Sent transaction: {transaction}')
You can see specifically how the metadata is built here
# Create the metadata with another index for each
nft_options = []
for index in range(nft_collection_size):
nft_number = index + 1
attribue_value = random.randint(42, 69)
immutable_metadata = bytes(json.dumps({
"standard": "IRC27",
"version": "v1.0",
"type": "image/png",
"uri": "ipfs://bafybeicnznoiprv5udy36wlrhqffa7evyaodewea343dnavgt3aqn4gwbm",
"name": f"Mudskipper #{nft_number}",
"description": "The Mudskipper",
"issuerName": "The Queen",
"collectionName": "The 30y old virgin collection",
"attributes": [
{
"trait_type": "Rarity",
"value": f"{attribue_value}"
}
]
}).encode('utf-8')).hex()