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

nem-payments

v1.1.3

Published

Returns an object including a list of confirmed NEM payments made using an identifying message/ID string for a particular address, as well as a payment total and the NEM node used.

Downloads

4

Readme

nem-payments

NEM payments is an easy to use module that returns an object (via a promise) containing a list of confirmed NEM transactions for a given NEM address. Only transactions that make use of a given message string in the transactions' 'message' field will be returned. A combined total of all payments made to the address using this message is also included (useful for payment confirmation and order fulfilment).

Installation

First install the module as you would any other:

$ npm i nem-payments

Import the module:

const nemPayments = require('nem-payments');

Usage

In its simplest form, your argument takes the form of three string parameters: a NEM address, a text message to look for, and optionally the node you wish to use for the query. If you don't specify a node URL it will carry out the query using the node http://62.75.163.236 (i.e. Alice3, chosen for no particular reason) by default. Note: you need to include the protocol in the node address.

The NEM address will automatically have have its dashes removed.

(async () => {
  const payments = await nemPayments(
    'NAER66-DXCNYE-BNMTWA-PKG7CU-27CMUP-TQQDSM-2KL6',
    'Hello World!',
    'http://62.75.163.236'
  ).catch(err => console.error(err));

  console.log(payments);
})();

For more control over the results, you may instead use an options object in place of the node string. This options object features a NEM node address string, and additional integer parameters to limit either/both of the numbers of transactions searched, and the number of positive results to return, respectively.

By default nem-payments will page through the entire history of an address's incoming transactions, so for accounts with a large number of transactions this might take a while. For payment/checkout flows you would typical only be interested in recent payments, and so might initially elect to limit the results of a search.

For example, if we needed to search through an exchange address for recent depositors who have forgotten to include their ID message, we can search for an empty string and limit the scope of our query with the searchLimit and maxResults parameters (here we haven't specified a node, so the default is used):

const options = {
  searchLimit: 250,
  maxResults: 10
};

const payments = await nemPayments(
  'NC64UF-OWRO6A-VMWFV2-BFX2NT-6W2GUR-K2EOX6-FFMZ',
  '',
  options
).catch(err => console.error(err));

Finally, you can also return a number of the most recent transactions by passing a non-string argument for the message parameter, bypassing the message filter entirely (for the sake of brevity, here we've limited the amount of transactions to search through):

const options = {
  searchLimit: 200
};

const payments = await nemPayments(
  'NC64UF-OWRO6A-VMWFV2-BFX2NT-6W2GUR-K2EOX6-FFMZ',
  null,
  options
);

Dependencies

nem-payments makes use of the NEM SDK (nem-sdk) to fetch incoming transactions.

There are also a couple of utility functions included to return a sum total of payments and filter out transactions that are either non-transfer transactions, or do not contain the message we're searching for. This filter transaction supports both standard and multisignature transactions, as the transaction objects for these differ in structure.