This project demonstrates the power of ERC998 composable NFTs through a car assembly example. Cars are composable NFTs that can own and be composed of various car parts (also NFTs), showcasing the "NFT of NFTs" concept.
ERC998 is a standard for composable NFTs that allows an NFT to own other NFTs and ERC20 tokens. This creates hierarchical ownership structures where a parent NFT can contain child tokens, enabling complex digital asset compositions.
Find more information about ERC998 here.
This demo project includes:
- Car Contract: ERC998 composable NFT representing cars that can own car parts
- Part Contracts: ERC721/ERC998 NFTs representing individual car parts (Engine, Wheel, FuelTank)
- Fuel Contract: ERC20 token representing fuel that can be owned by fuel tanks
- Interactive Demo Script: Comprehensive demonstration of car assembly and disassembly
- Node.js (v18 or higher)
Run the interactive demo script that demonstrates all ERC998 functionality:
- Clone the repository:
git clone https://github.com/maxnorm/erc998-demo-car.git- Install dependencies:
npm install- Run the development network (In another terminal):
npx hardhat node- Run the demo script & monitor the logs to see the demo:
npx hardhat run scripts/demo.ts --network localhostThis script will:
- Deploy Car, Engine, Wheel, FuelTank, and Fuel contracts
- Mint various car parts (engine, 4 wheels, fuel tank) and fuel
- Assemble parts into a complete car using different ERC998 methods
- Demonstrate part transfers and disassembly
- Show car sales with all nested ownership intact
- Verify ownership hierarchies throughout the process