UATU - Query on-chain data in natural language
PlaygroundNPM PackageAPI Dashboard
  • Problems UATU is solving
  • White Paper
    • Abstract
    • Introduction
      • Background and motivation
      • Objectives of UATU
      • Scope and limitations
    • UATU Architecture
      • Blockchain Nodes & Knowledge Database
      • UATU Services and Service-Specific Databases
      • UATU API Cluster
      • Natural Language Processing (NLP) module
      • UATU Query Language (UATU QL)
      • Data extraction and presentation
  • UATU Services
    • On-chain data services
      • Implementation details and data sources
    • Integration with third-party APIs (where applicable)
  • User Interface, API, and NPM Library
    • Playground for direct user queries
    • API for developers and organisations
    • UATU libraries
      • Installation and usage
      • Library features and functions
    • Security and access control mechanisms
  • Use Cases and Applications
    • End-user scenarios
    • Developer and organisation scenarios
  • Evaluation and Performance Metrics
  • Future Work and Enhancements
  • Conclusion
  • Appendix
    • UATU QL Syntax and Examples
    • Detailed Service Descriptions
    • API Documentation and Usage Examples
    • UATU Library Documentation and Usage Examples
  • Tokenomics
    • Distribution
    • Token Sale Rounds
    • User Metrics & Trade Data
    • Burning
    • Milestones
  • FAQs
    • AI Model & NLP
    • UATU QL
    • UATU Library
    • UATU APIs
    • UATU Services
      • Wallet
      • Ticker
  • Links & Social
    • Uatu Playground
    • UATU Dev Dashboard
    • Twitter
    • Telegram Community
    • LinkedIn
    • Discord
Powered by GitBook
On this page

Was this helpful?

  1. Appendix

UATU Library Documentation and Usage Examples

Overview:

We provide a brief overview of the UATU library for JavaScript, showcasing its features and usage examples. It is important to note that although this documentation focuses on the npm package for JavaScript, UATU is not limited to npm and will be available for various other programming languages in the future.

The UATU library for JavaScript is a convenient wrapper for the UATU API. It is written in TypeScript and can be used with both Node.js and browser applications. Developers can easily interact with the UATU services and fetch essential data related to wallets, assets, transactions, and NFTs.

Installation is straightforward, with different methods for Node.js and browser environments. Usage examples provided in the readme file demonstrate how to initialize the UATU object, verify wallets, watch events, and retrieve wallet, asset, transaction, and NFT information.

The library's objects, such as Wallet, Asset, Transaction, and NFT, contain a wealth of relevant data for developers to use in their applications. For example, Wallet objects include wallet addresses, assets, transactions, and NFT assets, while Asset objects contain information on value, symbol, and chain of the asset. Transaction objects provide details like hash, from/to addresses, value, transaction type, chain ID, coin, block number, transaction status, and timestamp. Finally, NFT objects include crucial data on token address, token ID, owner, block numbers, token hash, amount, contract type, name, symbol, token URI, minter address, chain ID, and timestamp.

Installation

To install the UATU library for JavaScript, follow the instructions based on your environment:

Node.js:

npm install uatujs

Browser:

//html

<script src="https://unpkg.com/uatujs@1.0.3/CommonJS/src/index.js"></script>

Usage Examples

Initialize UATU object:

//javascript 

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

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

const uatu = new UATU(wallet); 
uatu.verify(wallet); 

Watch events:

//javascript 

const watcher = uatu.watch();

watcher.on('connected', () => {
  console.log("UATU connected");
});
watcher.on('wallet', (wallet) => {
  console.log(wallet);
});
watcher.on('asset', (asset) => {
  console.log(asset);
});
watcher.on('transaction', (transaction) => {
  console.log(transaction);
});
watcher.on('nft', (nft) => {
  console.log(nft);
});
watcher.on('error', (error) => {
  console.log(error);
});
watcher.on('disconnected', () => {
  console.log("UATU disconnected");
});

Retrieve wallet information:

//javascript 

const wallets = uatu.ask('wallet').then((wallet) => {
  console.log(wallet);
});

Retrieve asset information:

//javascript

const assets = await uatu.ask('assets').then((assets) => {
  console.log(assets);
});

Retrieve transaction information:

//javascript

const transactions = await uatu.ask('transactions').then((transactions) => {
  console.log(transactions);
});

Retrieve NFT asset information:

//javascript

const nftAssets = await uatu.ask('nfts').then((nftAssets) => {
  console.log(nftAssets);
});

Objects

The UATU library provides several objects, such as Wallet, Asset, Transaction, and NFT, containing relevant data for developers to use in their applications.

Wallet Object:

Includes wallet addresses, assets, transactions, and NFT assets.

Asset Object:

Contains information on value, symbol, and chain of the asset.

Transaction Object:

Provides details like hash, from/to addresses, value, transaction type, chain ID, coin, block number, transaction status, and timestamp.

NFT Object:

Includes crucial data on token address, token ID, owner, block numbers, token hash, amount, contract type, name, symbol, token URI, minter address, chain ID, and timestamp.

PreviousAPI Documentation and Usage ExamplesNextDistribution

Last updated 2 years ago

Was this helpful?