Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

NFT Collection

A simple ERC-721 NFT Collection built with Solidity, OpenZeppelin, and Foundry. This project demonstrates the core functionality of an NFT collection, including minting, metadata management through baseURI, and tokenURI implementation.


Features

  • 🖼️ ERC-721 compliant NFT collection
  • 🎨 Mint new NFTs
  • 🔗 Configurable baseURI override
  • 📄 Custom tokenURI override

Tech Stack

  • Solidity ^0.8.x
  • Foundry
  • OpenZeppelin Contracts

Project Structure

.
├── src/
│   └── NFTCollection.sol
├── uris/
│   └── 0.json
│   └── 1.json
├── script/
│   └── DeployNFTCollection.s.sol
├── lib/
├── foundry.toml
└── README.md

Prerequisites

Install the following tools before running the project:

  • Git
  • Foundry

Install Foundry

curl -L https://foundry.paradigm.xyz | bash
foundryup

Verify the installation:

forge --version

Installation

Clone the repository:

git clone https://github.com/<your-username>/nft-collection.git
cd nft-collection

Install dependencies:

forge install

Build the project:

forge build

Compile

forge build

Run Tests

Run all tests:

forge test

Verbose output:

forge test -vvvv

Generate a gas report:

forge test --gas-report

Generate coverage:

forge coverage

Code Formatting

Format Solidity files:

forge fmt

Deployment

Start a local blockchain:

anvil

Deploy the contract:

forge script script/DeployNFTCollection.s.sol \
    --rpc-url http://127.0.0.1:8545 \
    --private-key <PRIVATE_KEY> \
    --broadcast

Contract Functions

Mint NFT

Creates a new NFT and assigns it to a recipient.

mint(address to);

Set Base URI

Updates the base URI used for metadata.

setBaseURI(string memory newBaseURI);

Example:

https://example.com/metadata/

Token URI

Returns the complete metadata URI for a token.

Example:

https://example.com/metadata/1.json

Implemented by overriding OpenZeppelin's tokenURI() function.


Example Metadata

{
  "name": "NFT #1",
  "description": "Example NFT Collection",
  "image": "ipfs://QmExampleHash/1.png",
  "attributes": [
    {
      "trait_type": "Rarity",
      "value": "Common"
    }
  ]
}

Testing

The test suite covers:

  • Contract deployment
  • NFT minting
  • Ownership verification
  • Token URI generation
  • Base URI updates
  • Invalid token lookups
  • Revert conditions

Run:

forge test

Useful Foundry Commands

Build

forge build

Run tests

forge test

Verbose tests

forge test -vvvv

Gas report

forge test --gas-report

Coverage

forge coverage

Format code

forge fmt

Clean artifacts

forge clean

Start local node

anvil

Interact with contracts

cast

Dependencies

  • OpenZeppelin Contracts
  • Forge Standard Library (forge-std)

License

This project is licensed under the MIT License.


Author

Developed with Solidity and Foundry for educational purposes and as a foundation for more advanced NFT projects.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages