# 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
//html

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

**Usage Examples**

*Initialize UATU object:*

```javascript
//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
//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
//javascript 

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

*Retrieve asset information:*

```javascript
//javascript

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

*Retrieve transaction information:*

```javascript
//javascript

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

*Retrieve NFT asset information:*

```javascript
//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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://uatu.gitbook.io/uatu/appendix/uatu-library-documentation-and-usage-examples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
