UNPKG

wallet-shortener

Version:

Simply short your Wallet Addresses in your project, to give your users a better UI and UX.

112 lines (75 loc) โ€ข 2.51 kB
# wallet-shortener A cute utility to shorten crypto wallet addresses like `0x81...cF2B`. Perfect for displaying wallet addresses in a clean, readable format in dApps, and when you click on it, you even have **click-to-copy** built in. --- ## ๐Ÿš€ Installation ```bash npm install wallet-shortener ``` --- ## โš™๏ธ Options You can also configure how many characters to show on the left and right, and disable **click-to-copy**: ```jsx <ShortAddress right={5} left={3} copyOnClick={false}>{address}</ShortAddress> // -> "0x81C...F2B" ``` --- ### โœ… Usage ```tsx import { ShortAddress } from "wallet-shortener"; export default function App() { return ( <ShortAddress> 0x81C75741Db32d6329127bd499a33e562462BcF2B </ShortAddress> ); } ``` ### ๐Ÿ” Props | Prop | Type | Default | Description | |--------------|----------|---------|----------------------------------------------| | `children` | `string` | โ€” | The full Ethereum wallet address | | `left` | `number` | `4` | Characters to show on the left | | `right` | `number` | `4` | Characters to show on the right | | `copyOnClick`| `boolean`| `true` | Copies the full address to clipboard on click| | `className` | `string` | `""` | Optional CSS class for styling | --- ## ๐Ÿ’ก Ideal for - Web3 dashboards - Wallet UIs - NFT marketplaces - DAO tools - dApps with address display --- ## ๐Ÿ“ฆ Lightweight & dependency-free - Zero dependencies - ESM-ready - TypeScript support - Works in Node.js, Vite, Next.js, or modern frontend frameworks --- ## ๐Ÿงช Example in Next.js ```tsx import { ShortAddress } from "wallet-shortener"; export default function WalletDisplay({ address }) { return ( <div> <ShortAddress>{address}</ShortAddress> </div> ); } ``` --- ## ๐Ÿ“ˆ npm Badges ![npm](https://img.shields.io/npm/v/wallet-shortener) ![downloads](https://img.shields.io/npm/dm/wallet-shortener) [โ†’ View on npm](https://www.npmjs.com/package/wallet-shortener) --- ## ๐Ÿง  Author **Julian** โ€“ Building Web3 tools and products. - GitHub: [https://github.com/JUlian-co](https://github.com/JUlian-co) - npm: [https://www.npmjs.com/package/wallet-shortener](https://www.npmjs.com/package/wallet-shortener) --- ## ๐Ÿ“œ License MIT โ€“ free to use, even commercially, idc. --- ๐ŸŒŸ โ†’ **Please give this repository a star to support me <3**