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

stellar-qr

v0.0.5

Published

QR code generation rules for different stellar wallets

Downloads

5

Readme

Stellar QR generator

This package is intended to fill current vacuum in the area of payment link generation and QR codes.

There were multiple attempts to come up with standard way of generating payment links and QR codes: https://galactictalk.org/d/12-formats-for-qr-codes-uris-nfcs

But decision have never been made and as a result nobody is really using Stellar for payments (it's hard and inconvenient for users to enter manually address + memo) and many services in Stellar ecosystem ask user for secret key, which is a very bad practice and must be eradicated.

How it works

Require this package into your project

npm i --save stellar-qr

Then use it in your code

const StellarQr = require('stellar-qr');

const wallets = StellarQr.wallets(); 
// returns list of wallets with support for QR codes

Currently returns:

  • Centaurus (QR code doesn't support memo, simply encodes public address)
  • Stargazer (QR code contains JSON structure with required fields)
  • Papaya (uses Stargazer format)
  • StellarKey (Builds transaction envelope, which is ready to be signed, but requires sourceAccount parameter, so you must ask user for his address first)

Then you offer user to choose wallet they are using and generate QR code for it:

const StellarQr = require('stellar-qr');
 
const link = StellarQr.getStellarLink({
  wallet: 'stargazer',
  accountId: '',
  amount: '0.01',
  assetCode: 'BTC',
  assetIssuer: 'GAUTUYY2THLF7SGITDFMXJVYH3LHDSMGEAKSBU267M2K7A3W543CKUEF',
  memoType: 'text',
  memo: 'KAUOsC3bTU2+V2LwT18vDg=='	
});
const svgString = StellarQr.getStellarQR(link);

And use svgString to show QR on your payment page

Parameters:

  • wallet - one from the list
  • networkHash - first 8 chars of sha256 hash of stellar network passphrase (7ac33997 - default, for public stellar network, cee0302d for testnet)
  • networkPassphrase - can be provided directly to derive networkHash
  • accountId - required, destination account for payment to be sent to
  • amount - amount of assets to send (optional for stargazer format, useless for centaurus format)
  • memoType - one of id, text, hash, return
  • memo - memo value
  • assetCode - asset code, default is XLM
  • assetIssuer - asset issuer, required if assetCode != XLM
  • sourceAccount - sender account, required for Stellarkey to prepare transaction envelope

You can also use it as frontend widget

<div id="stellar-qr"></div>
<link rel="stylesheet" href="https://swap.apay.io/stellar-qr/bundle/widget.css">
<script src="https://swap.apay.io/stellar-qr/bundle/widget.js"></script>
<script>
  window.STELLAR_QR_WIDGET.init({
  	container: document.getElementById('stellar-qr'), 
  	sourceAddress: userStellarAccount, // needed only for StellarKey 
  	amount: 123, 
  	currency: 'XLM', 
  	destinationAddress: yourStellarAccount, 
  	memoType: 'TEXT', 
  	memo: 'orderNumber'
  });
</script>