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

bitcoinaddress

v0.1.1

Published

bitcoinaddress.js is a a JavaScript UI component for making easy bitcoin payments, sending bitcoins and presenting bitcoin addresses on HTML pages.

Downloads

5

Readme

Introduction

bitcoinaddress.js is a a JavaScript component library for making easy bitcoin payments, sending bitcoins and presenting bitcoin addresses on HTML pages.

image

Features

  • Mobile and touch friendly - no pop-ups
  • Use Bitcoin URI protocol to make payments from your desktop, web or mobile bitcoin wallet
  • Generate QR codes in-fly with JavaScript to make payments from mobile applications
  • Copy Bitcoin address to the clipboard
  • Customize and extend easily with custom DOM templates and JavaScript hooks

Demos

See the demo.

Installation

No server-side components needed.

You must have jQuery (version 1.9 or later) installed.

Drop bitcoinaddress.js on your HTML page with optio elements as described below. Download minified or debug bundle from Github dist folder The bundle includes QRCode.js library (see below).

How it works

  • Include bitcoinaddress.js on your HTML page
  • Configure and initialize it with a <script> tag
  • Supply a client-side template in a hidden on your page
  • When the HTML page has been loaded, bitcoinaddress.init() scans for .bitcoin-address CSS classes, applies template on them and sets up UI event handlers

Setting up <script> tag:

<script src="bitcoinaddress-bundle.min.js"></script>
<script>
    $(document).ready(function() {
        bitcoinaddress.init({

            // jQuery selector defining bitcon addresses on the page
            // needing the boost
            selector: ".bitcoin-address",

            // Id of the DOM template element we use to decorate the addresses.
            // This must contain placefolder .bitcoin-address
            template: "bitcoin-address-template",

            // Passed directly to QRCode.js
            // https://github.com/davidshimjs/qrcodejs
            qr : {
                width: 128,
                height: 128,
                colorDark : "#000000",
                colorLight : "#ffffff"
            }
        });
    });
</script>

A DOM templating is used to built the controls for the Bitcoin addresses. Embed the following snippet hidden in and customize for your needs. See index.html for example CSS styles:

<div id="bitcoin-address-template" class="bitcoin-address-container" style="display: none">

    <div>
        <span class="bitcoin-address"></span>
    </div>

    <a href="#" class="bitcoin-address-action bitcoin-address-action-send">
        <i class="fa fa-btc"></i>
        Pay from wallet
    </a>

    <a href="#" class="bitcoin-address-action bitcoin-address-action-copy">
        <i class="fa fa-copy"></i>
        Copy
    </a>

    <a href="#" class="bitcoin-address-action bitcoin-address-action-qr">
        <i class="fa fa-qrcode"></i>
        QR code
    </a>

    <div class="bitcoin-action-hint bitcoin-action-hint-send">
        Sending payment to the address from locally installed Bitcoin wallet app.
    </div>

    <div class="bitcoin-action-hint bitcoin-action-hint-copy">
        Press CTRL + C or &#x2318; + C to copy the Bitcoin address.
    </div>

    <div class="bitcoin-action-hint bitcoin-action-hint-qr">
        <p>
            Scan the QR code with your mobile Bitcoin app to
            make the payment:
        </p>

        <div class="bitcoin-address-qr-container">
            <!-- Filled in by JS on action click -->
        </div>
    </div>

</div>

Then you can have Bitcoin addresses on your page, with or without payment amounts.

Plain Bitcoin address example:

<strong class="bitcoin-address" data-bc-address="19356KxTs9Bw5AAdxens5hoxDSp5bsUKse">19356KxTs9Bw5AAdxens5hoxDSp5bsUKse</strong>

Bitcoin address with payment amount example:

<strong class="bitcoin-address"
    data-bc-amount="0.1"
    data-bc-label="bitcoinaddress.js project"
    data-bc-message="0.1 BTC donation"
    data-bc-address="19356KxTs9Bw5AAdxens5hoxDSp5bsUKse">19356KxTs9Bw5AAdxens5hoxDSp5bsUKse</strong>

See the demo how to nominate the payment in the fiat currency using bitcoinprices.js library.

Supported data attributes

The following HTML5 data attributes are supported on .bitcoin-address elements

  • data-bc-address - bitcoin address for programmatical manipulation, required
  • data-bc-amount - suggestion how much to send
  • data-bc-label - address label in the wallet
  • data-bc-message - transaction message

NPM packaging

This project is also packaged and distributed on npmjs.org.

You can install the package with browserify and various other tools to include it in app JavaScript stack.

Other

See also bitcoin-prices.js JavaScript project for presenting Bitcoin prices in human-friendly manner and alternative currencies like USD and EUR.

Bitcoin URL scheme explained.

Bitcoin URIs in Electrum.

QRCode.js - generate QR codes in JavaScript by Shim Sangmin.

Development

NPM + Node required. A Makefile provides many commands to develop, test and publish this project.

browserify used for client-side module imports.

Install dependencies locally:

make setup

Run the development server with auto-reload (save bitcoinaddress.js in your text editor and the browser will reload index.html):

make dev-server

Run unit tests locally:

make test-server

Make a release:

make publish

Internals and the development toolchain

This package uses NPM, browserify for JavaScript dependencies, beefy development server, uglify-fs JavaScript minimizer.

tape unit testing framework runs the tests on testling continuous integration service infrastructure.

Check out Makefile if you want to learn how to use these tools.

Author

Mikko Ohtamaa (blog, Facebook, Twitter, Google+)

Contact for work and consulting offers.