New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

loogie-blo

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loogie-blo

loogie-blo is a small and fast library to generate Ethereum Loogies identicons. It is a fork of the original Blo library by bpierre.

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source
Loogie blo
loogie-blo is a small and fast library to generate Ethereum Loogies identicons.
It is a fork of the original Blo library by bpierre.

npm version bundle size License

Features

  • 🐥 Small: 0.75 KB gzipped.
  • 💥 Fast: 3.5x faster than the second fastest solution (performance from original blo).
  • 🔍 Optimized: Leverages SVG to generate compact and sharp images at any size.
  • 💆 Simple: Focuses on Ethereum identicons only, allowing for a simpler API.
  • 🗂 Typed: Ships with types included.
  • 👫 Works everywhere: browsers, Bun, Node.js.
  • ☁️ Zero dependencies.

Library Comparison

LibraryRenders/sec1SizeTypesEnvironment2Rendering
blo💥 8,197SVG
ethereum-blockies-base64807PNG
blockies-react-svg1,749SVG
@download/blockies334Canvas
blockies-ts342Canvas
react-blockies2,361Canvas

Getting Started

npm i -S loogie-blo
pnpm add loogie-blo
yarn add loogie-blo
import { loogieBlo } from "loogie-blo";

img.src = loogieBlo("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045");

React / Vue / Others

loogie-blo is fast enough to not require memoization or async rendering for common use cases.

function AddressIcon({ address }: { address: `0x${string}` }) {
  return (
    <img
      alt={address}
      src={loogieBlo(address)}
    />
  );
}

API

loogieBlo(address: Address, size = 64): string

Get a data URI string representing the identicon as an SVG image.

The size paramater shouldn’t usually be needed, as the image will stay sharp no matter what the size of the img element is.

Example:

import { loogieBlo } from "loogie-blo";

img.src = loogieBlo(address); // size inside the SVG defaults to 400px
img2.src = loogieBlo(address, 24); // set it to 24px
loogieBloSvg(address: Address, size = 64): string

Same as above except it returns the SVG code instead of a data URI string.

Types

The library ships with TypeScript types included.

// A color in the HSL color space.
// [0]: 0-360 (hue)
// [1]: 0-100 (saturation)
// [2]: 0-100 (lightness)
export type Hsl = Uint16Array;

// An Ethereum address.
export type Address = `0x${string}`;

Acknowledgements

FAQ

Does it follow the exact same algorithm as Etherscan, MetaMask and others?

Yes.

Does it work with ENS names?

No it only works with Ethereum addresses, but you can resolve the ENS name to an address (e.g. with wagmi) and pass the result to blo.

Can it be used to generate other types of identicons?

blo only focuses on the Ethereum identicons algorithm but you can use it with any data, just prefix it with 0x to fulfill the expected Address type if you are using TypeScript.

Why is it named blo?

blo is short for blockies, which is the name of the original library it is based on.

License

MIT

Footnotes

  • The number of renders per second. It was measured on Chrome 117 Linux with an AMD Ryzen 7 PRO 4750U. See ./benchmark for the methodology.

  • The term “all” refers to libraries that are framework agnostic and that run in browsers, Bun and Node.js.

Keywords

ethereum

FAQs

Package last updated on 29 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts