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

uatujs

v1.1.0

Published

npm library for UATU API

Downloads

12

Readme

UATU Library for JavaScript

Introduction

This is a JavaScript library for UATU. It is a wrapper for the UATU API. It is written in TypeScript and can be used in both Node.js and the browser. It is also available as a npm package.

Installation

Node.js

npm install uatujs

Browser

<script src="https://unpkg.com/[email protected]/CommonJS/src/index.js"></script>

Usage

const { UATU } = require('uatujs');
const { ethers } = require('ethers');

const wallet = new ethers.Wallet('0x...');

/**
 * Initialize UATU object.
 * `wallet` is optional here. But then you will have to call uatu.verify(wallet) before using the other functions of the UATU object. If Wallet is provided here, then it will * be verified automatically.
 * If you are not using ethers.js then you can provide the private key or mnemonic here. e.g. new UATU('0x...') or new UATU('mnemonic')
 */
const uatu = new UATU(wallet); 

// No need to call this if wallet is provided in the constructor.
uatu.verify(wallet); 

// Watch Events for the Wallet Address
const watcher = uatu.watch();
watcher.on('connected', () => {
  console.log("UATU connected");
});
watcher.on('wallet', (wallet) => {
  // Receives Wallet Object
  console.log(wallet); // <Wallet>
});
watcher.on('asset', (asset) => {
  // Receives Asset Object
  console.log(asset); // <Asset>
});
watcher.on('transaction', (transaction) => {
  // Receives Transaction Object
  console.log(transaction);  // <Transaction>
});
watcher.on('nft', (nft) => {
  // Receives NFT Object
  console.log(nft); // <NFT>
});
watcher.on('error', (error) => {
  console.log(error);
});
watcher.on('disconnected', () => {
  console.log("UATU disconnected");
});

// Get Wallets for the Wallet Address
const wallets = uatu.ask('wallet').then((wallet) => {
  // Returns Wallet Object
  console.log(wallet); // <Wallet>
});

// Get Assets(Coins and ERC20 Tokens) for the Wallet Address
const assets = await uatu.ask('assets').then((assets) => {
  // Returns array of Assets
  console.log(assets);  // [<Asset>]
});

// Get Transactions for the Wallet Address
const transactions = await uatu.ask('transactions').then((transactions) => {
  // Returns array of Transactions
  console.log(transactions);  // [<Transaction>]
});

// Get NFT Assets for the Wallet Address
const nftAssets = await uatu.ask('nfts').then((nftAssets) => {
  // Returns array of NFT Assets
  console.log(nftAssets); // [<NFT>]
});

Wallet Object <Wallet>

Wallet is an object that contains the wallet address and Transactions .

{
  "walletAddress": "0x8248734173c746ea29ae138117ef652266ae9f2b",
  "assets": [
    <Asset>
  ],
  "transactions": [
    <Transaction>
  ],
  "nftAssets": [
    <NFT>
  ]
}

Asset Object <Asset>

Asset is an object that contains the value , symbol and chain of the asset.

{
  "value": 300,
  "symbol": "<CoinSymbol>",
  "chain": "<ChainName>",
}

Transaction Object <Transaction>

Transaction is an object that contains the hash , fromAddress , toAddress , value , txnType , chainId , coin , blockNumber , txnStatus and timestamp of the transaction.

{
  "hash": "0xe12b7ac0cdcbcba0d42740539198ba52b503a914551002f6c45e21e9c923e416",
  "fromAddress": "0x0000000000000000000000000000000000000000",
  "toAddress": "0xf2f5c73fa04406b1995e397b55c24ab1f3ea726c",
  "value": 1,
  "txnType": "RECIEVE",
  "chainId": 1,
  "coin": "<CoinSymbol>",
  "blockNumber": 15586637,
  "txnStatus": true,
  "timestamp": 1629200000
}

NFT Object <NFT>

NFT is an object that contains the token_address , token_id , owner_of , block_number , block_number_minted , token_hash , amount , contract_type , name , symbol , token_uri , minter_address , chainId and timestamp of the NFT.

{
  "token_address": "0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85",
  "token_id": "34812922231052332207600408151355793147729817622833157082448925652934526198815",
  "owner_of": "0xf2f5c73fa04406b1995e397b55c24ab1f3ea726c",
  "block_number": 15568803,
  "block_number_minted": 15568742,
  "token_hash": "a23198f8badee88f2650ea9f0dfcb175",
  "amount": 1,
  "contract_type": "ERC721",
  "name": "Ethereum Name Service",
  "symbol": "ENS",
  "token_uri": null,
  "minter_address": "0x26e850e94b0b7b672544a5b60ac3463957a817ba",
  "chainId": 1,
  "timestamp": 1629200000
}

Coin Symbol <CoinSymbol>

Coin Symbol is a string that represents the symbol of the coin. e.g. ETH , BTC , USDT , DAI . See Full List of Coin Symbols here.

Chain Name <ChainName>

Chain Name is a string that represents the name of the chain. e.g. Ethereum , Binance Smart Chain , Polygon , Avalanche . See Full List of Chain Names here.