A unique NFT collection on Base network that implements a "stake to reveal" mechanism where NFTs evolve over time based on staking duration. Each NFT can level up every 7 days while staked, reaching a maximum level of 10, with each level providing increased power and new visual attributes.
- ERC721A implementation for gas-efficient minting
- Stake-to-evolve mechanism with 7-day evolution periods
- Progressive level system (max level: 10)
- Evolution stages: Novice → Adept → Master → Legend
- Power boost system (10% increase per level)
- Dynamic metadata and visuals based on NFT level
- Transfer restrictions for staked NFTs
- Gas-optimized contract design
- Each NFT starts at Level 1
- NFTs must be staked to begin evolution
- Evolution occurs every 7 days of continuous staking
- Maximum level cap of 10
- Each level provides a 10% power boost
-
Novice (Levels 1-3)
- Initial evolution stage
- Basic power capabilities
-
Adept (Levels 4-6)
- Intermediate evolution
- Enhanced attributes
-
Master (Levels 7-9)
- Advanced evolution
- Superior capabilities
-
Legend (Level 10)
- Final evolution stage
- Maximum power achieved
The smart contract is deployed on Base network and includes the following key functionalities:
mint(address to, uint256 quantity): Mint new NFTssetBaseURI(string baseURI_): Set the base URI for metadata
stake(uint256 tokenId): Start the evolution processlevelUp(uint256 tokenId): Evolve NFT after staking periodunstake(uint256 tokenId): Stop evolution processgetLevel(uint256 tokenId): Check current leveltimeUntilNextLevelUp(uint256 tokenId): View remaining timeisStaked(uint256 tokenId): Check staking status
- Node.js (v14+ recommended)
- npm or yarn
- A wallet with Base network tokens for deployment
- Base RPC URL (Mainnet/Testnet)
- Basescan API Key (for contract verification)
- IPFS account for metadata storage (recommended)
- Clone the repository:
git clone <repository-url>
cd evolving-legacy-nft- Install dependencies:
npm install- Create
.envfile:
cp .env.example .env- Fill in your environment variables in
.env:
BASE_GOERLI_RPC_URL=your_base_goerli_rpc_url
BASE_MAINNET_RPC_URL=your_base_mainnet_rpc_url
PRIVATE_KEY=your_private_key
BASESCAN_API_KEY=your_basescan_api_key
METADATA_BASE_URI=your_metadata_base_uriRun the comprehensive test suite:
npm testnpm run compilenpm run generate-metadataTo Base Goerli testnet:
npm run deploy:goerliTo Base mainnet:
npm run deploy:mainnetnpm run verify <contract-address> --network base-goerliThe metadata follows the OpenSea standard with additional evolution-specific attributes:
{
"name": "Evolving Legacy NFT #<tokenId>",
"description": "Level <level> Evolving Legacy NFT - A unique NFT that evolves through staking",
"image": "ipfs://<CID>/<tokenId>_<level>.png",
"attributes": [
{
"trait_type": "Level",
"value": "<level>",
"max_value": 10
},
{
"trait_type": "Evolution Stage",
"value": "<Novice/Adept/Master/Legend>"
},
{
"display_type": "boost_percentage",
"trait_type": "Power Boost",
"value": "<level * 10>"
}
]
}Generates metadata files for all NFTs at each level:
npm run generate-metadataTo interact with the deployed contract:
- Update
YOUR_CONTRACT_ADDRESSinscripts/interact.js - Use the provided functions in the script
- Run:
npx hardhat run scripts/interact.js --network base-goerli- Access Control: OpenZeppelin's
Ownablepattern for admin functions - Staking Security: NFTs cannot be transferred while staked
- Evolution Verification: Level-up requirements strictly enforced on-chain
- Time Manipulation: Block timestamps used with appropriate safety margins
- Gas Optimization: ERC721A for efficient minting and transfers
-
Before Deployment
- Run full test suite
- Generate and upload all metadata to IPFS
- Verify gas costs for all operations
-
After Deployment
- Verify contract on Basescan
- Test all functions on testnet
- Set proper base URI
- Document contract address
-
Maintenance
- Monitor staking activity
- Track evolution progress
- Backup metadata and images
Common issues and solutions:
-
Staking Issues
- Verify NFT ownership
- Check if NFT is already staked
- Ensure proper approval
-
Level Up Failures
- Confirm staking duration requirement
- Check current level vs max level
- Verify caller is NFT owner
-
Metadata Issues
- Verify base URI is set correctly
- Check IPFS gateway status
- Confirm metadata file format
MIT License