A fully on-chain dynamic NFT that displays the owner's ENS name and ETH balance with generated text based on balance thresholds. All metadata and SVG are stored on-chain with no external dependencies.
- Fully On-chain: All metadata and SVG generated on-chain
- Dynamic Content: Updates based on:
- Owner's ENS name (or address if no ENS)
- Owner's ETH balance (with 5 decimal precision)
- Generated motivational text based on balance
- OpenSea Compatible: Inherits from
ERC721SeaDropfor full marketplace compatibility - Modular Architecture: Separated into three contracts for clean code organization
Mainnet: [INSERT_CONTRACT_ADDRESS_HERE]
Sepolia Testnet: 0xAd7d830A332239fd95058aD058F2Db2128b56e7b
The project consists of three main contracts:
The core ERC721 contract that combines all functionality and generates the dynamic tokenURI.
contract NFTCard is ERC721SeaDrop, SVG, ENSManagerHandles all ENS integration to retrieve the owner's ENS name from on-chain data.
Key Features:
- Queries ENS reverse registrar to get the node for an address
- Resolves the node to get the resolver address
- Retrieves the ENS name from the resolver
- Falls back to displaying the address if no ENS name exists
function getName(address _user) public view returns (bool, string memory name)Contains all SVG constants and styling for the NFT card generation.
Features:
- Gold gradient styling
- Matte black background
- Structured text elements for balance, status text, and owner info
The NFT displays different text based on the owner's balance:
- < 1 ETH: "Try harder bro"
- 1-10 ETH: "Well, thats not bad"
- > 10 ETH: "Proof-of-Degen"
Balance is displayed with 5 decimal precision (e.g., "2.50000 Ether")
- Clone the repository:
git clone <your-repo-url>
cd NFT- Install dependencies:
forge install- Create a
.envfile in the root directory:
cp .env.example .env- Fill in your
.envfile with your credentials:
# RPC URLs
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_ALCHEMY_KEY
MAINNET_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_ALCHEMY_KEY
# Private Key (WITHOUT 0x prefix)
PRIVATE_KEY=your_private_key_here
# Etherscan API Key (works for both testnet and mainnet)
ETHERSCAN_API_KEY=your_etherscan_api_key_here.env file! Make sure it's in .gitignore.
Run tests with verbose output:
make testRun tests with debug mode:
make test-debugOr using forge directly:
forge test -vvvvmake deploy-sepoliaThis command will:
- Compile the contracts with optimization
- Deploy to Sepolia
- Automatically verify on Etherscan
- Display gas costs and contract address
make deploy-mainnetNote: This command includes a confirmation prompt to prevent accidental mainnet deployments.
Expected deployment cost at 0.268 gwei: ~$5-6 USD (based on ~6M gas)
The project includes a Makefile for easy command execution:
| Command | Description |
|---|---|
make test |
Run all tests with verbose output (-vvvv) |
make test-debug |
Run tests in debug mode for step-by-step execution |
make deploy-sepolia |
Deploy to Sepolia testnet with verification |
make deploy-mainnet |
Deploy to Ethereum mainnet with verification (includes confirmation) |
make help |
Display all available commands |
The project uses aggressive optimization settings in foundry.toml:
- Default profile:
optimizer_runs = 200,via_ir = true - Sepolia profile:
optimizer_runs = 10000(optimized for deployment cost) - Mainnet profile:
optimizer_runs = 1000000(maximum size optimization)
These settings reduce the contract size from 32,931 bytes to 20,814 bytes, fitting within the 24,576-byte limit.
The NFT card features:
- Gold gradient styling with multiple color stops
- Matte black background with rounded corners
- Dynamic balance display with 5 decimal places
- ENS name or address display at the bottom
- Status text that changes based on balance
Example output:
┌─────────────────────────────────┐
│ │
│ MrPicule fam │
│ │
│ Your balance is 2.50000 Ether │
│ │
│ Well, thats not bad │
│ │
│ │
│ MrPicule.eth │
└─────────────────────────────────┘
- Original size: 32,931 bytes ❌
- Optimized size: 20,814 bytes ✅
- Achieved through
via_ir = trueand highoptimizer_runs
- Sepolia deployment: ~4.8M gas
- Estimated mainnet:
6M gas ($5-6 at 0.268 gwei)
The contract integrates with ENS using:
IReverseRegistrar- to get the node for an addressENSregistry - to resolve the node to a resolverINameResolver- to get the actual name
All queries are view functions with no gas cost for reading.
MIT License - see LICENSE file for details
Contributions are welcome! Please feel free to submit a Pull Request.
Created by MrPicule - GitHub
Built with ❤️ using Foundry and Solidity