Skip to content

A lightweight library to format Ethereum addresses.

Notifications You must be signed in to change notification settings

reecejohnson/eth-address

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm version downloads

eth-address

A lightweight library to format Ethereum addresses. Easily truncate any eth address to a desired length.

Installation

npm

npm install eth-address

yarn

yarn add eth-address

Functions

formatEthereumAddress

formatEthAddress(address: string, chars: number = 4): string;

Formats a given Ethereum address at the desired length each side of the "..." separator.

Usage

Importing

JavaScript

const formatEthAddress = require('eth-address');

JavaScript (ES6) / TypeScript

import { formatEthAddress } from 'eth-address';

Example

import { formatEthAddress } from 'eth-address';

const address = '0x61289A6b7819203749E409c7d62427Df7aD36dD7';

const formattedAddressWithDefaultChars = formatEthAddress(address);

// formattedAddressWithDefaultChars result
'0x6128...6dD7'

const charactersASide = 6;
const formattedAddressWith6Chars = formatEthAddress(address, charactersASide);

// formattedAddressWith6Chars result
'0x61289A...D36dD7'

About

A lightweight library to format Ethereum addresses.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published