@ensdomains/etherloom

中文文档
0.1.0-alpha.4发布于 2026/07/13MITTypeScriptCommonJS零依赖近 30 天下载 2300

Deterministic SVG weave patterns generated from an Ethereum address.

原始使用文档
文档目录6 节
  1. Usage
  2. Identity: an ENS name, an address, or both
  3. Scripts
  4. Interactive demo
  5. Patterns
  6. License

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 namehash so 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) and threads (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
namehashaddressresult
setomittedname avatar, stable across transfers (ENS-native)
setsetname avatar that changes with the owner
zero / omittedsetaddress 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

版本与发布记录

@ensdomains/etherloom 共发布 4 个版本,首次发布于 2026/06/26;过去 12 个月发布了 4 个版本。

版本发布日期距今
0.1.0-alpha.4latest2026/07/134 个月前
0.1.0-alpha.3alpha2026/07/034 个月前
0.1.0-alpha.22026/06/294 个月前
0.1.0-alpha.12026/06/264 个月前

关于 @ensdomains/etherloom 的常见问题

@ensdomains/etherloom 是什么?

Deterministic SVG weave patterns generated from an Ethereum address.

如何安装 @ensdomains/etherloom?

在项目目录运行 npm install @ensdomains/etherloom,或使用 pnpm add / yarn add / bun add。

@ensdomains/etherloom 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ensdomains/etherloom 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@ensdomains/etherloom 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@ensdomains/etherloom 可以商用吗?

@ensdomains/etherloom 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ensdomains/etherloom 的下载量有多少?

根据 npm 官方下载统计,@ensdomains/etherloom 在 2026/10/14 – 2026/11/12 这 30 天内被下载 2,300 次,日均约 77 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ensdomains/etherloom 还在维护吗?

最新版本 0.1.0-alpha.4 发布于 2026/07/13(4 个月前);至今共发布 4 个版本,其中过去 12 个月发布了 4 个;首次发布于 2026/06/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。