Skip to content

cypherpulse/NFT-Development-Genesis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

79 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NFT Development Genesis

Foundry Solidity License: MIT GitHub Issues GitHub Pull Requests

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.

πŸ“‹ Table of Contents

πŸ”§ Prerequisites

Before you begin, ensure you have the following installed:

  • Foundry (Forge, Cast, Anvil, Chisel)
  • Git
  • Node.js (optional, for additional tooling)

Verify your Foundry installation:

forge --version

πŸ“¦ Installation

  1. Clone the repository:

    git clone https://github.com/cypherpulse/NFT-Development-Genesis.git
    cd NFT-Development-Genesis
  2. Install dependencies:

    forge install
  3. Build the project:

    forge build

πŸ’» Usage

Development Workflow

  1. Start a local development node:

    anvil
  2. Deploy contracts locally:

    forge script script/DeployBasicNft.s.sol --fork-url http://localhost:8545 --broadcast
  3. Interact with contracts using Cast:

    cast call <contract_address> "name()" --rpc-url http://localhost:8545

Key Contracts

  • BasicNft.sol: Core ERC-721 NFT contract with minting functionality.

Deployment Scripts

  • 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 NFT

Or use the Makefile:

make deploy ARGS="--network base-sepolia"
make Mint ARGS="--network base-sepolia"

πŸ§ͺ Testing

Run the comprehensive test suite:

forge test

Run tests with gas reporting:

forge test --gas-report

Run specific tests:

forge test --match-path test/BasicNftTest.t.sol

Test Coverage

  • testNameIsCorrect: Verifies the contract name is "Cypherpulse".
  • testCanMintAndHaveBalance: Tests minting functionality, balance, and token URI retrieval.

πŸš€ Deployment

Live Deployment on Base Sepolia

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 Other Networks

Deploy to a testnet or mainnet:

  1. Set up your environment variables (create a .env file):

    PRIVATE_KEY=your_private_key_here
    RPC_URL=https://your-rpc-url-here
    ETHERSCAN_API_KEY=your_api_key_here
  2. Deploy using the script:

    forge script script/DeployBasicNft.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast --verify

    Note: Add --verify for contract verification on Etherscan/Basescan.

Token ID Assignment

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_URL

🎨 SVG Creation and NFT Artwork

What is SVG?

SVG (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

Creating SVG Artwork

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

Example: Happy Face SVG

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>

Rendered Image: Happy Face SVG

Using SVG in NFTs

To use SVG in your NFTs:

  1. Encode to Base64: Convert SVG to base64 for on-chain storage
  2. Create tokenURI: Return data:image/svg+xml;base64,<encoded_svg> from tokenURI()
  3. 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.

Contributing

We welcome contributions from the community! Here's how you can get involved:

Development Process

  1. Fork the repository

  2. Create a feature branch:

    git checkout -b feature/your-feature-name
  3. Make your changes and add tests

  4. Run the test suite:

    forge test
  5. Format your code:

    forge fmt
  6. Commit your changes:

    git commit -m "Add: Brief description of your changes"
  7. Push to your fork:

    git push origin feature/your-feature-name
  8. Create a Pull Request

Guidelines

  • 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

Code of Conduct

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.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

If you have questions or need help:

πŸ™ Acknowledgments

  • Foundry - The toolkit powering this project
  • OpenZeppelin - For secure smart contract libraries
  • The Ethereum community for continuous innovation

Built with ❀️ by the Cypherpulse team

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors