MintGPT

Generating images with AI tools is fascinating, and minting NFTs is equally exciting. So, why not fuse these two exciting prospects to create a compelling application? With the aid of AI tools and the Underdog Protocol, the task is now easier than ever. This tutorial blog post will guide you through the process of building MintGPT, leveraging the aforementioned tools.

What is Underdog Protocol?

Underdog Protocol is a platform that assists developers and startups in simplifying their interactions with digital collectibles. It allows them to seamlessly integrate web3 into their products or workflows to enhance their user experience.

Here are some useful resources :

The technologies used in this project include:

  • Underdog protocol
  • Next.js
  • GPT 3.5
  • DALL-E API
  • Solana blockchain
  • Wallet adapter for Solana
  • Tailwind CSS

Generating API keys

Before diving into the application development, we need to generate our API keys for Underdog, GPT 3.5, and DALL-E APIs. Visit OpenAI and Underdog Protocol, click on 'Get Started', and connect your wallet. Once inside the dashboard, click on 'API keys' and generate your API key to access the Underdog Protocol REST APIs.

The application follows this workflow:

the flow basically has 4 main steps in the process

  1. The user connects their wallet to the app and inputs a word.
  2. This word is dispatched to the ChatGPT API to generate a prompt based on the input.
  3. The generated prompt is used to create an image with an AI tool, such as DALL-E.
  4. The resultant image is sent to the Underdog 'Create NFT' API for minting as an NFT.

Making API calls

Before making all necessary API calls to the tools and protocols, ask the user to connect their wallet. Using the Solana wallet adapter and Solana web3.js packages, implement a 'connect wallet' button that detects installed wallets on the user's browser and prompts them to connect.

Once this step is complete, the user can input a random word of their choice in the text field on the frontend. This word is then sent to the OpenAI API endpoint via a POST method to generate the prompt.

Upon successful generation of the text, use it as a prompt to create an image. This requires hitting another API endpoint. The image URL received in the response is stored for further use.

At this point, we are close to our goal. The last step is to mint the image using the Underdog 'Create NFT' API. This is achieved by making a post request to the following endpoint:

COPY

COPY

https://dev.underdogprotocol.com/v2/projects/{type}/{projectId}/nfts

the implementation would look something like below

And there you have it! We have successfully minted an NFT generated by an AI tool based on the provided prompt.
Congratulations on this achievement! 🎉

You can experiment with the code of the live application provided in the link. Feel free to contribute to the app. Let's delve into another tutorial soon, and until then, keep buildin.