Avatar Types
ENS avatars can be set using multiple formats:- NFT Avatar: Any ERC-721 or ERC-1155 NFT you own
- IPFS: Decentralized image hosting via IPFS
- HTTP/HTTPS: Standard image URLs
- Data URIs: Base64-encoded images
Setting an Avatar
Configure your ENS avatar during registration or update it later:Choose Avatar Source
Select from your NFT collection or provide an image URL.
- Browse your NFT collection
- Enter an IPFS hash
- Provide an HTTP(S) URL
- Upload an image (converted to IPFS)
Preview Avatar
Preview how your avatar will appear in profiles and throughout the wallet.The avatar is displayed:
- In the registration confirmation
- On your profile screen
- When sending transactions
- In contact suggestions
Avatar Resolution
Rainbow uses a sophisticated avatar resolver that supports multiple formats:src/handlers/ens.ts
The
AvatarResolver library automatically handles NFT metadata parsing, IPFS gateway resolution, and image format detection.NFT Avatars
NFT avatars are the most common avatar type:NFT URI Format
NFT avatars use the following format:Ownership Verification
The avatar resolver can verify NFT ownership:NFT Metadata Resolution
For NFT avatars, the resolver:- Parses the NFT URI format
- Calls the NFT contract’s
tokenURI()method - Fetches the metadata JSON
- Extracts the
imagefield - Resolves IPFS/HTTP URLs through gateways
- Returns the final image URL
Header Images
ENS also supports header/cover images:src/handlers/ens.ts
- On profile screens
- In expanded ENS views
- When viewing ENS details
Avatar Caching
Avatars are cached for performance:src/handlers/ens.ts
- Cache-first: Check local cache before fetching
- Preloading: Load images before display
- Local storage: Save fetched avatars
- 10-minute stale time: Refresh after 10 minutes
Image Processing
Rainbow processes avatar images through Imgix:src/handlers/ens.ts
- Automatic image optimization
- Responsive sizing
- Format conversion (WebP, AVIF)
- CDN delivery
Avatar Display
Avatars are displayed throughout the wallet:In Registration
src/screens/ENSConfirmRegisterSheet.tsx
In Suggestions
src/handlers/ens.ts
- ENS name as nickname
- Avatar image if available
- Fallback to generated color
- Ethereum address
In Contact Lists
Contacts with ENS names display their avatars automatically when resolved.Updating Avatars
Change your avatar at any time:Avatar Metadata
Avatar metadata is stored in React state:src/components/ens-registration/RegistrationAvatar/RegistrationAvatar.tsx
- Preview before committing
- Temporary avatar selection
- Rollback on cancel
SVG Avatars
ENS NFT avatars are SVG by default:src/handlers/ens.ts
- Dynamically generated
- Based on ENS name
- Unique color scheme
- Hosted by ENS metadata service
ENS NFTs have built-in SVG avatars even without setting a custom avatar. The SVG is generated from the name itself.
Fallback Behavior
When avatars fail to load:- Try cached image from local storage
- Show ENS-generated SVG avatar
- Display color-based placeholder
- Show wallet address initials
src/handlers/ens.ts
Performance Optimization
- Lazy loading: Avatars load on demand
- Prefetching: Predictive loading for suggestions
- Size optimization: Request appropriate image sizes
- Format selection: WebP/AVIF when supported
- CDN caching: Imgix CDN for global delivery