Skip to content

web3pavlou/foundry-NFT-f23

Repository files navigation

Basic & Mood NFT

NFT Demos contains two examples of ERC‑721 non‑fungible tokens built with the Foundry framework.

Overview

  • BasicNftoff-chain IPFS metadata.
  • MoodNftfully on-chain SVG that flips between HAPPY and SAD.

Getting Started

Requirements

  • Git
  • Foundry (forge,cast,anvil)
  • An Ethereum wallet and RPC endpoint (e.g. Sepolia or mainnet)

Quickstart

git clone https://github.com/web3pavlou/foundry-NFT-f23
cd foundry-NFT-f23
forge install
forge build

Usage

Start a local node

make anvil

Testing

forge test -vvvv

or

forge test --fork-url $SEPOLIA_RPC_URL

Test coverage

forge coverage

Deployment to a testnet or mainnet

Set your SEPOLIA_RPC_URL and PRIVATE_KEY as environment variables.Deployment is handled via the scripts located in the script/ directory:

# Deploy the BasicNft contract
make deploy $ARGS
# Deploy the MoodNft contract (reads and encodes SVGs)
make deployMood $ARGS

After deployment, you can mint or flip tokens using the interaction scripts:

# Mint a BasicNft (uses a constant IPFS URI)
make mint $ARGS
# Mint a MoodNft 
make mintMoodNft $ARGS
# Flip the mood of token 0 on the most recent MoodNft deployment
make flipMoodNft $ARGS

Optionally, add your ETHERSCAN_API_KEY if you want to verify your contract on Etherscan.

Base64

To get the base64 of an image, you can use the following command:

echo "data:image/svg+xml;base64,$(base64 -i ./images/dynamicNft/happy.svg)"

Then, you can get the base64 encoding of the json object by placing the imageURI into happy_image_uri.json then running:

echo "data:application/json;base64,$(base64 -i ./images/dynamicNft/happy_image_uri.json)"

License

This project is licensed under the MIT License. See the LICENSE file for full license text.

Acknowledgements

  • Cyfrin Updraft – Thanks to @patrickalphaC for the educational material
  • Foundry – For the dev tools
  • OpenZeppelin-For battle-tested libs

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published