Skip to content

yug49/foundry-dynamicNFT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

foundry-dynamicNft

It is a smart contract project written in Solidity using Foundry.

  • It a smart contract I developed leveraging Foundry.
  • It is a dynamic ERC-721 token (NFT) I developed using OpenZeppline library.
  • It is a SVG NFT that is 100% stored on chain, hence completly decentralized.
  • User can change the mood of the nft (Happy / Sad) by calling the "flipMood(uint256)" function.

Getting Started

  • git: You'll know you did it right if you can run git --version and you see a response like git version x.x.x
  • foundry: You'll know you did it right if you can run forge --version and you see a response like forge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)
  • make (optional - either you can install make or you can simply substitute the make commands with forge commands by referring to the Makefile after including your .env file): You'll know you did it right if you can run make --version and you will see a response like GNU Make 3.81...

Installation

  • Install foundry-dynamicNft
    git clone https://github.com/yug49/foundry-dynamicNft
    cd foundry-dynamicNft
  • Make a .env file
    touch .env
  • Open the .env file and fill in the details similar to:
    SEPOLIA_RPC_URL=<YOUR SEPOLIA RPC URL>
    ETHERSCAN_API_KEY=<YOUR ETHERSCAN API KEY>
    SEPOLIA_PRIVATE_KEY=<YOUR PRIVATE KEY>
  • Remove pre installed cache, unecessary or partially cloned modules modules etc.
    make clean
    make remove
  • Install dependencies and libraries.
    make install
  • Build Project
    make build
## Deployment

Deploy On a Local Network (Anvil Testnet)

  • To Deploy on a local network first run anvil on your local terminal in current directory by running coommmand: make anvil.
  • Now open another terminal and let this one run in the background
  • Run the following command:
make deploy

Deploy on a Sepolia or Any Other Network

  • To Deploy on Sepolia, after successfully creating .env file as mentioned above.
  • Get youself some Sepolia Eth and LINK tokens and then run command:
make deploy ARGS="--network sepolia"

Scripts

  • After deploying to a testnet or local net, you can run the scripts.

  • Using cast mint yourself a mood NFT:

cast call <CONTRACT_ADDRESS> "mintNft()" --rpc-url --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEY --legacy -vvvvv
  • After minting, you can change flip the mood by:
cash call <CONTRACT_ADDRESS> "flipMood(uint256)" <TOKEN_ID> --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEY --legacy -vvvvv

You can also use Etherscan to interact with the contract:

  • Open sepolia.etherscan.io.
  • Search your deployed token contract address.
  • Click on Contract tab > Read Contract / Write Contract.
  • Connect your web3 wallet.

Estimate gas

You can estimate how much gas things cost by running:

make snapshot

Testing

  • for local anvil
    make test

Formatting

  • to format all the solidity files:
    make format

Coverage

  • To get test coverage report.
make test-coverage

🔗 Links

Loved it? lets connect on:

twitter linkedin

About

A dynamic SVG NFT that allows user to change the mood of the NFT according to his wish.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published