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.
- git: You'll know you did it right if you can run
git --versionand you see a response likegit version x.x.x - foundry: You'll know you did it right if you can run
forge --versionand you see a response likeforge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z) - make (optional - either you can install
makeor 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 runmake --versionand you will see a response likeGNU Make 3.81...
- 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
- 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- 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"-
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- Open sepolia.etherscan.io.
- Search your deployed token contract address.
- Click on Contract tab > Read Contract / Write Contract.
- Connect your web3 wallet.
You can estimate how much gas things cost by running:
make snapshot- for local anvil
make test- to format all the solidity files:
make format- To get test coverage report.
make test-coverageLoved it? lets connect on: