A comprehensive toolkit for developing, testing, and deploying ERC-721 NFTs on Ethereum using Foundry. This project serves as a genesis for NFT development, providing robust smart contracts, thorough testing, and deployment scripts to kickstart your Web3 journey.
- NFT Development Genesis
Before you begin, ensure you have the following installed:
Verify your Foundry installation:
forge --version-
Clone the repository:
git clone https://github.com/cypherpulse/NFT-Development-Genesis.git cd NFT-Development-Genesis -
Install dependencies:
forge install
-
Build the project:
forge build
-
Start a local development node:
anvil
-
Deploy contracts locally:
forge script script/DeployBasicNft.s.sol --fork-url http://localhost:8545 --broadcast
-
Interact with contracts using Cast:
cast call <contract_address> "name()" --rpc-url http://localhost:8545
BasicNft.sol: Core ERC-721 NFT contract with minting functionality.
deploy-sepolia.sh: Deploys the contract to Base Sepolia testnet.mint-sepolia.sh: Mints an NFT on the deployed contract.
Run the scripts:
./deploy-sepolia.sh # Deploys the contract
./mint-sepolia.sh # Mints an NFTOr use the Makefile:
make deploy ARGS="--network base-sepolia"
make Mint ARGS="--network base-sepolia"Run the comprehensive test suite:
forge testRun tests with gas reporting:
forge test --gas-reportRun specific tests:
forge test --match-path test/BasicNftTest.t.soltestNameIsCorrect: Verifies the contract name is "Cypherpulse".testCanMintAndHaveBalance: Tests minting functionality, balance, and token URI retrieval.
The contract has been successfully deployed and tested on Base Sepolia:
- Contract Address:
0xBaAa6adfcEc14E8ebCD4abBb9cfc8C77367aA57e - Basescan Contract Page: View on Basescan
- Deployment Transaction: View Transaction
- Minted NFT Transaction: View Transaction
- Minted Token ID: 0
- Token URI:
ipfs://bafybeig37ioir76s7mg5oobetncojcm3c3hxasyd4rvid4jqhy4gkaheg4/?filename=0-PUG.json
Deploy to a testnet or mainnet:
-
Set up your environment variables (create a
.envfile):PRIVATE_KEY=your_private_key_here RPC_URL=https://your-rpc-url-here ETHERSCAN_API_KEY=your_api_key_here
-
Deploy using the script:
forge script script/DeployBasicNft.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast --verify
Note: Add
--verifyfor contract verification on Etherscan/Basescan.
Token IDs are assigned sequentially starting from 0:
- First minted NFT: Token ID 0
- Second minted NFT: Token ID 1
- And so on...
You can retrieve token information using:
cast call <contract_address> "tokenURI(uint256)" <token_id> --rpc-url $RPC_URL
cast call <contract_address> "ownerOf(uint256)" <token_id> --rpc-url $RPC_URLSVG (Scalable Vector Graphics) is an XML-based vector image format for two-dimensional graphics. It's perfect for NFTs because:
- Scalable: Looks crisp at any size without pixelation
- Lightweight: Small file sizes compared to raster images
- On-chain friendly: Can be stored directly in smart contracts
- Customizable: Easily modifiable with code
You can create SVG graphics using:
- Code editors: Write raw SVG markup
- Design tools: Adobe Illustrator, Inkscape (export to SVG)
- Online editors: SVG-edit, Boxy SVG
- Programming: Generate dynamically with JavaScript/Solidity
Here's a simple happy face SVG created for this project:
<svg viewBox="0 0 200 200" width="400" height="400" xmlns="http://www.w3.org/2000/svg">
<circle cx="100" cy="100" fill="greenyellow" r="78" stroke="black" stroke-width="3" />
<g class="eyes">
<circle cx="61" cy="82" r="12" />
<circle cx="127" cy="82" r="12" />
</g>
<path d="m136.81 116.53c.69 26.17-64.11 42-81.52-.73" style="fill:none; stroke: black; stroke-width: 3;" />
</svg>To use SVG in your NFTs:
- Encode to Base64: Convert SVG to base64 for on-chain storage
- Create tokenURI: Return
data:image/svg+xml;base64,<encoded_svg>fromtokenURI() - Store on IPFS: Upload SVG to IPFS for off-chain storage (as done in this project)
The minted NFT in this project uses an IPFS-hosted SVG as its metadata.
We welcome contributions from the community! Here's how you can get involved:
-
Fork the repository
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes and add tests
-
Run the test suite:
forge test -
Format your code:
forge fmt
-
Commit your changes:
git commit -m "Add: Brief description of your changes" -
Push to your fork:
git push origin feature/your-feature-name
-
Create a Pull Request
- Follow the Solidity Style Guide
- Write comprehensive tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting a PR
- Use clear, descriptive commit messages
This project adheres to a code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to maintainers@cypherpulse.com.
This project is licensed under the MIT License - see the LICENSE file for details.
If you have questions or need help:
- π§ Email: support@cypherpulse.com
- π¬ Discord: Join our community
- π Issues: GitHub Issues
- π Documentation: Foundry Book
- Foundry - The toolkit powering this project
- OpenZeppelin - For secure smart contract libraries
- The Ethereum community for continuous innovation
Built with β€οΈ by the Cypherpulse team