This feature allows OnchainRugs to display Cryptopunk engravings on the back of rugs when owned by Cryptopunk holders.
- Dynamic Display: When a rug NFT is viewed, the system checks if the current owner also owns any Cryptopunks
- Automatic Engraving: If they do, their Cryptopunk is engraved on the rug's back
- Test Mode: During development, you can test different punk patterns locally
-
Open the generator page
-
Select "Crypto Punk" from the Mask Type dropdown
-
Choose from preset punk patterns:
- Classic: Basic face
- Beanie: Punk with beanie hat
- Cap: Baseball cap
- Hoodie: Hoodie strings
- Pipe: Smoking pipe
- Crazy Hair: Spiky hair
- Mohawk: Shaved sides, mohawk
- Wild Hair: Flowing hair
- Nerd Glasses: Thick glasses
- Regular Shades: Sunglasses
- Custom: Enter specific Punk ID (0-9999)
-
Click "Load Real SVGs from Files" to see authentic Cryptopunk engravings
-
Download all punk SVGs:
# Replace YOUR_RPC_URL with your Alchemy or Infura endpoint node scripts/download-punks.js "https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY"
-
Load into generator:
- Click "Load Real SVGs from Files"
- Select any punk ID to see the actual engraving
data/cryptopunks/ # Downloaded punk SVG batches
โโโ index.json # Batch index file
โโโ punks-000.json # Punks 0-99
โโโ punks-001.json # Punks 100-199
โโโ ...
scripts/
โโโ download-punks.js # SVG downloader script
lib/GeometricPatterns.ts # Pattern rendering with punk support
app/generator/page.tsx # UI controls for punk selection
- Parses
<rect>elements from Cryptopunk SVGs - Converts to 24x24 boolean pixel arrays
- Supports real-time engraving generation
- Real SVGs: Exact pixel-perfect reproduction
- Test Patterns: Algorithmic generation of punk features
- Positioning: Centered on rug back, 15% of canvas size
- Lazy Loading: SVGs loaded only when needed
- Caching: Pixel arrays cached after parsing
- Rate Limiting: Built-in delays for RPC calls
For production deployment:
- Contract Integration: Modify
tokenURI()to check punk ownership - SVG Embedding: Include punk SVG in HTML generation
- Gas Optimization: Cache ownership checks and SVG data
// Load test patterns
await patternRenderer.loadPunksFromFiles();
// Load real punks from files
await patternRenderer.loadPunksFromFiles();
// Create engraving mask
const mask = patternRenderer.createMask('crypto_punk', params, palette, width, height, punkId);- Copyright: Cryptopunk SVGs are owned by Larva Labs
- Rate Limits: Respect RPC provider limits when downloading
- Storage: 10k SVGs = ~50MB of JSON data
- Performance: Real SVG parsing is slower than test patterns
- Dynamic Ownership: Real-time punk ownership checking
- Multiple Punks: Support for multiple punk engravings
- Engraving Styles: Different engraving depths and effects
- Animation: Punk animations on rug hover
Ready to test? Select "Crypto Punk" in the generator and try different patterns! ๐จโจ