Skip to content

BuildsWithKing/nft-smart-contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NFT Smart Contracts

A collection of NFT smart contracts built with Solidity and Foundry, featuring an IPFS-based NFT and a dynamic on-chain SVG NFT with mood-flipping functionality.


Contracts

BasicNFT (src/BasicNFT.sol)

A standard ERC-721 NFT contract where token metadata is stored off-chain via IPFS. Each token is minted with a custom URI pointing to its metadata hosted on IPFS.

Key Features:

  • ERC-721 compliant via OpenZeppelin
  • Per-token URI storage
  • Open minting — any address can mint

MoodNFT (src/MoodNFT.sol)

A fully on-chain dynamic NFT whose image and metadata are stored entirely on-chain as base64-encoded SVGs. Token owners can flip their NFT between a Happy and Sad mood at any time.

Key Features:

  • Fully on-chain SVG metadata — no IPFS or external dependency
  • Dynamic token URI that changes based on current mood
  • Mood flipping restricted to token owner or approved address
  • ERC-721 compliant via OpenZeppelin

Project Structure

├── script
│   ├── DeployBasicNFT.s.sol       # Deployment script for BasicNFT
│   ├── DeployMoodNFT.s.sol        # Deployment script for MoodNFT
│   └── Interactions.s.sol         # Mint interaction script
├── src
│   ├── BasicNFT.sol               # IPFS-based NFT contract
│   └── MoodNFT.sol                # On-chain SVG dynamic NFT contract
└── test
    ├── integrations
    │   ├── BasicNFTTest.t.sol
    │   ├── DeployMoodNFTTest.t.sol
    │   └── MoodNFTIntegration.t.sol
    └── unit
        └── MoodNFTTest.t.sol

Getting Started

Prerequisites

Installation

git clone https://github.com/BuildsWithKing/nft-smart-contract
cd nft-smart-contract
forge install

Build

forge build

Test

forge test

Coverage

forge coverage

Deployment

Local (Anvil)

Start a local Anvil node:

make anvil

Deploy contracts locally:

make deploy

Sepolia Testnet

Create a .env file at the project root:

SEPOLIA_RPC_URL=your_sepolia_rpc_url
ETHERSCAN_API_KEY=your_etherscan_api_key

Then run:

make deploy-sepolia

Interactions

Mint a MoodNFT on Sepolia after deployment:

make mint-sepolia

Environment Variables

Variable Description
SEPOLIA_RPC_URL RPC endpoint for Sepolia testnet
ETHERSCAN_API_KEY API key for contract verification

Dependencies


Author

MichealKing@BuildsWithKing


License

This project is licensed under the MIT License.

About

A collection of NFT smart contracts built with Solidity and Foundry, featuring an IPFS-based NFT and a dynamic on-chain SVG NFT with mood-flipping functionality.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors