@ensdomains/etherloom
v0.1.0-alpha.4
Published
Deterministic SVG weave patterns generated from an Ethereum address.
Readme
etherloom
Deterministic SVG weave patterns for ENS names - a generative, on-chain-ready
avatar for every name. The same name always looms the same identicon, and different
names render different cloth, so nick.eth and vibes.eth are instantly
distinguishable. Bind a name to its owner and the weave is re-woven when the name
changes hands.
- ENS-native. Seed from a name's
namehashso every name gets its own weave; combine it with the owner address so the pattern changes on transfer, or use the name alone for an identity that stays put across transfers. - Plain Ethereum addresses work too. No ENS name? Pass a bare address for the classic wallet identicon - same library, no extra setup, output unchanged.
- The identity picks the weave; the color is a parameter you pass and never changes the structure (recolor any identity freely).
- 18 named weaves, two render styles:
tiles(default, icon look - two-tone vertical pills on a soft frame) andthreads(dense fabric). - Effectively unique per identity: it deterministically picks one of 18 weaves
(via
patternForIdentity/generateIdenticon) and seeds each variant, so distinct identities don't collide. See Identity.
Usage
import {
generateIdenticon,
patternForIdentity,
generatePattern,
generatePatternDataURI,
generateAllPatterns,
listPatterns,
} from "./etherloom";
import { namehash } from "viem/ens";
// ENS-native: one woven avatar per name (color is required, #RGB or #RRGGBB).
generateIdenticon({ namehash: namehash("vitalik.eth") }, "#f03090");
// Bind the name to its owner so the weave changes hands with the name.
generateIdenticon({ address: "0xd8dA…6045", namehash: namehash("vitalik.eth") }, "#f03090");
// No ENS name? A bare address still works - the classic wallet identicon.
generateIdenticon("0xd8dA…6045", "#f03090");
// Which weave a name maps to, and picking the weave yourself:
patternForIdentity({ namehash: namehash("nick.eth") }); // -> "Herringbone", etc.
generatePattern({ namehash: namehash("nick.eth") }, "Herringbone", "#f03090"); // explicit weave override
// options: backgroundColor, style ("tiles" | "threads"), width, height, cellSize
generatePattern({ namehash: namehash("nick.eth") }, "2-2 Twill", "#3366cc", { width: 240, height: 240, cellSize: 24 });
generatePattern("0xd8dA…6045", "Herringbone", "#f03090", { style: "threads" });
generateAllPatterns({ namehash: namehash("nick.eth") }, "#2e9e5b"); // all 18 as SVG
generatePatternDataURI({ namehash: namehash("nick.eth") }, "Basket Weave", "#ff9800"); // data: URI for <img>Identity: an ENS name, an address, or both
Every entry point takes an identity. The ENS-native path is a name's
namehash - a precomputed bytes32 node from viem's
namehash() or @ensdomains/ensjs. This library stays dependency-free and never
normalizes names itself, so you pass the node, not the name string:
import { namehash } from "viem/ens";
// Name only: one avatar per name, stable across ownership transfers.
generateIdenticon({ namehash: namehash("vitalik.eth") }, "#f03090");
// Name + owner: the weave is re-woven if the name changes hands.
generateIdenticon({ address: "0xd8dA…6045", namehash: namehash("vitalik.eth") }, "#f03090");
// Power user / no ENS: a bare address string, or a zero / omitted namehash -
// the classic wallet identicon, byte-for-byte unchanged.
generateIdenticon("0xd8dA…6045", "#f03090");
generateIdenticon({ address: "0xd8dA…6045", namehash: "0x0" }, "#f03090"); // same as above| namehash | address | result |
| -------------- | --------- | ------------------------------------------------------ |
| set | omitted | name avatar, stable across transfers (ENS-native) |
| set | set | name avatar that changes with the owner |
| zero / omitted | set | address identicon (power user / no ENS) |
The 0x prefix and case of the namehash don't matter, and the all-zero ENS root
node (0x0) is the "no name" sentinel that falls back to address-only seeding.
Scripts
pnpm install
pnpm test # node:test suite
pnpm demo # console demo
pnpm gallery # write gallery.html and open it (optional: pnpm gallery 0xAddr "#color")Interactive demo
docs/ has two static pages - enter an ENS name or Ethereum address
(resolved with viem) and a color:
identicon.html- one identity-driven weave (generateIdenticon)index.html- all 18 patterns for comparison
pnpm build:web
pnpm dlx serve docs
# identicon -> http://localhost:3000/identicon.html
# all patterns -> http://localhost:3000/Patterns
Matt Rib Irregular · ENS Vertical Pairs · Plain Weave · Warp Rib Regular · Weft Rib Regular · Satin Weave · Houndstooth · Sateen Weave · Royal Oxford · 2-2 Twill · 3-3 Twill · Weft Rib Irregular · Warp Rib Irregular · Basket Weave · Point Twill · Curtain · Herringbone · 738 Diagonal Plus
License
MIT © ENS Labs
