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

@nexajs/address

v23.12.25

Published

A comprehensive suite of Address querying, monitoring and formatting utilities.

Downloads

65

Readme

NexaJS Address

A comprehensive suite of Address querying, monitoring and formatting utilities.

Contents

Data Schema

Here is the full data schema for a NexaJS Address.

{
  type: String
  prefix: String
  hash: String
  balance: BigInt
  received: BigInt
  sent: BigInt
  unconfirmed: BigInt
  transactions: String[txid]
  createdAt: Integer
  updatedAt: Integer
}

NOTE: All BigInt amounts are measured in satoshis (ie. 0.01 NEX).

Prefix

The prefix can be either nexa: or nexatest: for Mainnet and Testnet respectively.

Type

The Address type can be one of:

  • P2PKH
  • SCRIPT
  • TEMPLATE
  • GROUP

(Public Key) Hash

This is the public key hash for the Address.

Balance

This is the current "confirmed" NEXA balance.

Received

The total amount of NEXA received by this Address.

Sent

The total amount of NEXA sent from this Address.

Unconfirmed

This is the current "unconfirmed" NEXA balance.

Transactions

A list of all txidem(s) associated with this Address.

Created At

The timestamp of the first block confirmation for this Address.

Updated At

The timestamp of the most recent transaction associated with this Address.

Address Methods

encodeAddress(string|array)

Creates a Base58-encoded Nexa address.

decodeAddress(string|array)

Disassembles a Base58-encoded Nexa address.

getAddress(string|array)

Retrieve the latest on-chain data about an Address.

see Data Schema above

listUnspent(string|array)

Retrieve a list of ALL unspent transaction outputs.

Option #1: Import from (Package) Method

NOTE: This is the recommended option.

import { listUnspent } from '@nexajs/address'

const myAddress = 'nexa:nqtsq5g5sjkqk7wzd9wwh9423rr0tda7m027ryljkfy84cjz'

const unspent = await listUnspent(myAddress)
console.log(unspent)
/*
[
  {
    height: 301991,
    outpoint: '65102a067b574b7bd3cad9ad51f1907d94dadebdc24fd1db3742e76d6f1786b7',
    txid: '0cb7c4825931c696be4bc55185a534aeb08596860eaf97356ed978fcd3f3c06b',
    pos: 0,
    amount: 5.46,
    satoshis: 546,
    tokenid: 'nexa:tptlgmqhvmwqppajq7kduxenwt5ljzcccln8ysn9wdzde540vcqqqcra40x0x',
    tokenidHex: '57f46c1766dc0087b207acde1b3372e9f90b18c7e67242657344dcd2af660000',
    tokens: '100000000',
    hasToken: true
  },
  {
    height: 303280,
    outpoint: 'e6cecbc1c67d3b8587986abc768f2be946d3515442e61b3869953807dae69579',
    txid: '6af1d65fdc3a858ff8d1ce2044532f3765d4848eba1e8ae08609519436793e37',
    pos: 2,
    amount: 49910.15,
    satoshis: 4991015,
    hasToken: false
  }
]
*/

Option #2: Import from (Core Library) Method

import Nexa from 'nexajs'

const myAddresses = [
  'nexa:nqtsq5g5sjkqk7wzd9wwh9423rr0tda7m027ryljkfy84cjz',
  'nexa:nqtsq5g5lsgc2yns89kjp2ws4u7wk2d3lvzjznt3v8k2td59',
]

await Nexa.listUnspent(myAddresses)

watchAddress(string|array)

Allows you to monitor ALL on-chain activity for an Address.

Option #1: Import from (Package) Method

NOTE: This is the recommended option.

import { watchAddress } from '@nexajs/address'

const myAddress = 'nexa:nqtsq5g5ynxl8rwp5pzh47muagnn795pckdgtjrtatyzv2p5'

const myHandler = (updatedInfo) => {
    console.log(updatedInfo)
}

const cleanup = await watchAddress(myAddress, myHandler)
// cleanup() // Execute to cancel (and cleanup) an Address subscription.

Option #2: Import from (Core Library) Method

import Nexa from 'nexajs'

const myAddresses = [
  'nexa:nqtsq5g5ynxl8rwp5pzh47muagnn795pckdgtjrtatyzv2p5',
  'nexa:nqtsq5g5lsgc2yns89kjp2ws4u7wk2d3lvzjznt3v8k2td59',
]

const cleanup = await Nexa.watchAddress(myAddresses, myHandler)
// cleanup() // Execute to cancel (and cleanup) an Address subscription.

Setting a Custom Configuration

/* Set advanced parameters. */
const params = {
  address: [
    'nexa:nqtsq5g5ynxl8rwp5pzh47muagnn795pckdgtjrtatyzv2p5',
    'nexa:nqtsq5g5lsgc2yns89kjp2ws4u7wk2d3lvzjznt3v8k2td59',
    'nexa:nqtsq5g54v4772je5xq2z2t2aqgmaayavn44ttz5qd8cmfy2',
  ],
  handler: myHandler, // (optional) Set your notifications handler in your parameters.
  conn: {
    provider: [
      {
        type: 'rostrum',
        src: 'rostrum.myawesomeproject.com:20004',
      },
      {
        type: 'graphql',
        src: 'https://myawesomeproject.com/graphql',
      },
    ],
    threshold: 1,
    timeout: 5000,
  },
}

const cleanup = await watchAddress(params)
// cleanup() // Execute to cancel (and cleanup) an Address subscription.