npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

crypto-qr-code

v1.1.0

Published

A library to generate QR codes for cryptocurrency wallet addresses.

Downloads

34

Readme

crypto-qr-code

crypto-qr-code License

crypto-qr-code is a library for generating QR codes for cryptocurrency wallet addresses, supporting Bitcoin (BTC) and Ethereum (ETH). It provides options for customizing the QR code's format and currency type.

Installation

You can install crypto-qr-code via npm: npm install

npm install crypto-qr-code

Usage

Here's how to use the library:

import crypto-qr-codeGenerator from 'crypto-qr-code';

const qrGenerator = new crypto-qr-codeGenerator();

async function generateQRCode() {
    try {
        const qrCodeImage = await qrGenerator.generateQRCode('your_wallet_address', { currency: 'BTC' });
        console.log(qrCodeImage); // Outputs the QR code as a base64-encoded image
    } catch (error) {
        console.error(error);
    }
}

generateQRCode();

Options

The generateQRCode method accepts two parameters:

  1. address: The wallet address for the cryptocurrency (required).
  2. options: An object that can include:
    • currency: The type of cryptocurrency (default: BTC). Options are BTC for Bitcoin and ETH for Ethereum.
    • format: The desired image format for the QR code (default: image/png). Options are image/png, image/jpeg, and image/svg+xml.

Error Scenarios

  1. Empty Wallet Address: The wallet address is a required parameter.
  2. Invalid Currency: At present, we support only BTC and ETH.
  3. Invalid Wallet Address: If the provided address is not according to the standards, an error will be thrown.
  4. QR Code Generation Error: If there is problem generating the QR code, an error will be thrown.

Examples

  • Here’s a full example of generating a QR code for a Bitcoin address:
const qrCodeImage = await qrGenerator.generateQRCode('your_btc_wallet_address', { currency: 'BTC', format: 'image/png' });
console.log(qrCodeImage); // Base64 encoded PNG image
  • Here’s a full example of generating a QR code for a Ethereum address:
const qrCodeImageETH = await qrGenerator.generateQRCode('your_eth_wallet_address', { currency: 'ETH', format: 'image/jpeg' });
console.log(qrCodeImageETH); // Base64 encoded JPEG image

License

This project is licensed under the MIT License - see the LICENSE file for details.