Skip to content

Latest commit

ย 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽจ Mood NFT - Transform Your Emotions Into Art

Generate AI-powered artwork from your mood descriptions and mint them as unique NFTs on the Arbitrum network.

Arbitrum OpenAI IPFS Solidity

๐Ÿ› Challenge: Fix the Bugs!

This project contains 5 intentional bugs for learning purposes. Your task is to find and fix them all to make the app work!

Hints

# Hint Difficulty
1 Check if the AI model name actually exists ๐ŸŸข Easy
2 Look at URLs character by character... something looks Cyrillic ๐Ÿ‘€ ๐Ÿ”ด Hard
3 JavaScript is case-sensitive. Check function names match the contract ๐ŸŸก Medium
4 Config file path has a typo ๐ŸŸข Easy
5 Solidity functions that only read data need a special keyword ๐ŸŸก Medium

Error Messages You'll See

โŒ Image generation failed: Invalid model
โŒ Failed to upload to IPFS: Network error
โŒ Minting failed: Function not found
โŒ Configuration validation failed
โš ๏ธ Contract compilation warning

Good luck! ๐Ÿ€


โœจ Features

  • ๐ŸŽจ AI Image Generation: Uses DALL-E 3 to create stunning artwork from your mood descriptions
  • ๐Ÿ”— IPFS Storage: Decentralized storage via Pinata for images and metadata
  • โ›“๏ธ Arbitrum Network: Low gas fees and fast transactions on Ethereum L2
  • ๐Ÿ“ฑ Interactive CLI: User-friendly command-line interface
  • ๐Ÿ” ERC-721 Standard: Fully compliant NFT smart contract

๐Ÿ“‹ Prerequisites

  • Node.js 18+
  • An Ethereum wallet with some ETH on Arbitrum (or Arbitrum Sepolia for testing)
  • API keys for:
    • OpenAI - for DALL-E image generation
    • Pinata - for IPFS storage

๐Ÿš€ Quick Start

1. Clone and Install

git clone <your-repo>
cd mood-nft-arbitrum
npm install

2. Configure Environment

Copy the example environment file and fill in your credentials:

# Windows
copy config.env.example config.env

# Mac/Linux
cp config.env.example config.env

Edit config.env with your settings:

# Your wallet private key (without 0x prefix)
PRIVATE_KEY=your_private_key_here

# OpenAI API key
OPENAI_API_KEY=sk-your-openai-key

# Pinata credentials
PINATA_API_KEY=your_pinata_key
PINATA_SECRET_KEY=your_pinata_secret

# Contract address (after deployment)
CONTRACT_ADDRESS=your_contract_address

3. Compile the Smart Contract

npm run compile

4. Deploy the Contract

For testnet (Arbitrum Sepolia):

npm run deploy:sepolia

For mainnet (Arbitrum One):

npm run deploy

After deployment, copy the contract address to your .env file.

5. Create Your First Mood NFT

npm run mint

๐ŸŽฎ Usage

Run the interactive CLI:

npm run mint

Available Actions:

  1. ๐ŸŽจ Create new Mood NFT - Describe your mood and generate unique artwork
  2. ๐Ÿ“Š View my NFTs - See all your minted Mood NFTs
  3. ๐Ÿ’ฐ Check wallet balance - View your ETH balance and current gas prices
  4. ๐Ÿšช Exit - Close the application

Example Mood Descriptions:

  • "Peaceful Sunday morning with coffee, watching rain through the window"
  • "Excited about new possibilities, like the first day of spring"
  • "Nostalgic memories of childhood summers at the beach"
  • "Focused determination, pushing through challenges"

๐Ÿ“ Project Structure

mood-nft-arbitrum/
โ”œโ”€โ”€ contracts/
โ”‚   โ””โ”€โ”€ MoodNFT.sol          # ERC-721 NFT smart contract
โ”œโ”€โ”€ scripts/
โ”‚   โ””โ”€โ”€ deploy.js            # Deployment script
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ index.js             # Main CLI application
โ”‚   โ””โ”€โ”€ services/
โ”‚       โ”œโ”€โ”€ imageGenerator.js # DALL-E image generation
โ”‚       โ”œโ”€โ”€ ipfsUploader.js   # Pinata IPFS upload
โ”‚       โ””โ”€โ”€ nftMinter.js      # Blockchain interactions
โ”œโ”€โ”€ test/
โ”‚   โ””โ”€โ”€ MoodNFT.test.cjs     # Contract tests
โ”œโ”€โ”€ generated_images/         # Locally saved images
โ”œโ”€โ”€ hardhat.config.cjs        # Hardhat configuration
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ README.md

๐Ÿงช Running Tests

npm test

๐ŸŒ Networks

Arbitrum Sepolia (Testnet)

Arbitrum One (Mainnet)

๐Ÿ’ก Getting Test ETH

  1. Get Sepolia ETH from a faucet:

  2. Bridge to Arbitrum Sepolia:

Or use the Arbitrum Sepolia faucet directly:

๐Ÿ”ง Troubleshooting

"Contract artifact not found"

Run npm run compile to compile the smart contract.

"Insufficient funds"

Make sure your wallet has enough ETH on the selected network.

"OPENAI_API_KEY is not set"

Check that your .env file contains valid API keys.

Image generation fails

  • Check your OpenAI API key
  • Ensure you have API credits
  • Try simplifying your mood description

๐Ÿ“„ Smart Contract

The MoodNFT contract is an ERC-721 compliant NFT with additional features:

  • mintMoodNFT: Mint a new NFT with mood description and metadata URI
  • getMood: Get the mood description for any token
  • getMintTimestamp: Get when a token was minted
  • getTokensByOwner: Get all tokens owned by an address
  • getTotalMinted: Get total number of NFTs minted

๐Ÿ”— Useful Links

โš ๏ธ Security Notice

  • NEVER share your private key
  • NEVER commit your .env file to git
  • Use a dedicated wallet for testing
  • Start with testnet before using mainnet

๐Ÿ“œ License

MIT License - feel free to use this project for learning and personal use!


Made with โค๏ธ for the Web3 community

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages