# 2.5 Advanced NFT Minting Process

AI MONSTER leverages the Solana blockchain to create unique, tradable, and upgradable NFTs for each generated monster. This integration allows for a dynamic and interactive ecosystem where monsters can evolve, be trained, and gain value over time.

Each AI-generated monster is minted as a unique NFT on the Solana blockchain, ensuring verifiable ownership and scarcity. Our minting process incorporates the following advanced features:

1. **On-chain Metadata**: We store critical monster attributes directly on-chain for improved transparency and accessibility.
2. **Upgradable NFTs**: Utilizing Metaplex's Token Metadata program to allow for future upgrades and modifications.
3. **Royalty Distribution**: Implementing a fair royalty system that rewards original creators and contributors to monster evolution.

Here's an enhanced example of minting an AI Monster NFT on Solana:

```javascript
const web3 = require("@solana/web3.js");
const { Metaplex, keypairIdentity, bundlrStorage } = require("@metaplex-foundation/js");
const { DataV2, createCreateMetadataAccountV3Instruction } = require("@metaplex-foundation/mpl-token-metadata");

async function mintAIMonsterNFT(connection, payer, monsterData) {
  const metaplex = Metaplex.make(connection)
    .use(keypairIdentity(payer))
    .use(bundlrStorage());

  // Create on-chain metadata
  const { uri: metadataUri } = await metaplex.nfts().uploadMetadata({
    name: monsterData.name,
    symbol: "AIMON",
    description: monsterData.description,
    image: monsterData.imageUrl,
    attributes: monsterData.attributes,
    properties: {
      files: [{ uri: monsterData.imageUrl, type: "image/png" }],
      category: "image",
      creators: [{ address: payer.publicKey.toBase58(), share: 100 }],
    },
  });

  // Mint the NFT
  const { nft } = await metaplex.nfts().create({
    uri: metadataUri,
    name: monsterData.name,
    sellerFeeBasisPoints: 500, // 5% royalty
    symbol: "AIMON",
    creators: [{ address: payer.publicKey, share: 100 }],
    isMutable: true, // Allows for future upgrades
    maxSupply: 1, // Ensures uniqueness
  });

  console.log("Minted AI Monster NFT:", nft.address.toBase58());
  return nft;
}

// Usage
const connection = new web3.Connection(web3.clusterApiUrl("mainnet-beta"));
const payer = web3.Keypair.generate(); // Replace with actual wallet
const monsterData = {
  name: "Chronos the Cybernetic Hydra",
  description: "A time-manipulating, multi-headed monster with advanced AI capabilities.",
  imageUrl: "https://aimonster.io/images/chronos.png",
  attributes: [
    { trait_type: "Rarity", value: "Legendary" },
    { trait_type: "Power Level", value: 95 },
    { trait_type: "Ability", value: "Time Warp" },
  ],
};

mintAIMonsterNFT(connection, payer, monsterData);
```

