Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

web3-avatar

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-avatar

Generate beautiful Web3 address gradient avatar

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
200
decreased by-50.12%
Maintainers
1
Weekly downloads
 
Created
Source

web3 avatar preview image

Web3 Avatar - vanilla JavaScript

Web3 Avatar is a lightweight JavaScript library for generating beautiful gradient avatars from Ethereum addresses. This is vanilla JavaScript version of the library. If you are looking for other versions like Vue or React, please check the main repository. Inspired by Web3 Modal avatar.


🖥️ Live Demo

See live demo on web3-avatar.netlify.app


📦 Installation

You can install the library using npm:

npm install web3-avatar # or yarn add web3-avatar

Usage

The library exports a single function that takes two arguments: the element to render the avatar in and the Ethereum address to generate the avatar from. The element can be either a DOM element or a CSS selector. After the function is called, the element inline styles will be updated to render the avatar.

import createWeb3Avatar from 'web3-avatar';

createWeb3Avatar(element, address);

Example

<div id="#avatar"></div>
import Web3Avatar from 'web3-avatar';

createWeb3Avatar('#avatar', '0x11Ed0AC7D6142481E459B6e5d4bfB5646277796f');
// or
const someElement = document.querySelector('#avatar');
createWeb3Avatar(someElement, '0x11Ed0AC7D6142481E459B6e5d4bfB5646277796f');

📖 API

createWeb3Avatar(element, address)

Creates a Web3 Avatar in the given element.

Arguments
  • element - DOM element or CSS selector
  • address - Ethereum address
Returns
  • undefined

getGradientColors(address)

Returns the gradient colors for the given Ethereum address.

Arguments
  • address - Ethereum address
Returns
  • colors - Array of colors for gradient in rgb format

Test

npm run test # or yarn test

License

Released under the MIT License.

Keywords

FAQs

Package last updated on 28 Feb 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc