# skytale-commons

> Skytale utilities and most common used types

Latest version **1.6.6** (published 2023-02-03) · ISC license · 0 weekly downloads

## Install

```sh
npm install skytale-commons
pnpm add skytale-commons
yarn add skytale-commons
bun add skytale-commons
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.6.6 |
| Published | 2023-02-03 |
| First published | 2022-03-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 112.5 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| Author | Skytale |
| Maintainers | skytale.finance |

## Links

- npm: https://www.npmjs.com/package/skytale-commons
- Repository: https://gitlab.com/skytale-finance/skytale-commons
- Homepage: https://gitlab.com/skytale-finance/skytale-commons#readme
- Issues: https://gitlab.com/skytale-finance/skytale-commons/issues
- npm.io page: https://npm.io/package/skytale-commons

## Dependencies (7)

- [web3](https://npm.io/package/web3.md) 1.7.1
- [axios](https://npm.io/package/axios.md) ^0.26.0
- [dotenv](https://npm.io/package/dotenv.md) ^16.0.0
- [json-to-ts](https://npm.io/package/json-to-ts.md) ^1.7.0
- [generic-pool](https://npm.io/package/generic-pool.md) ^3.8.2
- [cache-manager](https://npm.io/package/cache-manager.md) ^3.6.0
- [@types/cache-manager](https://npm.io/package/@types/cache-manager.md) ^3.4.2

## Recent versions

- 1.6.6 (latest) — 2023-02-03
- 1.6.5 — 2023-01-30
- 1.6.4 — 2023-01-30
- 1.6.3 — 2023-01-30
- 1.6.2 — 2023-01-30
- 1.6.1 — 2023-01-30
- 1.5.0 — 2022-11-28
- 1.4.6 — 2022-11-17
- 1.4.5 — 2022-11-17
- 1.4.4 — 2022-11-17
- 1.4.3 — 2022-08-24
- 1.4.2 — 2022-07-31
- 1.4.1 — 2022-07-31
- 1.4.0 — 2022-07-26
- 1.3.1 — 2022-04-12
- … 11 more at https://npm.io/package/skytale-commons/versions

## README

# Skytale Commons

Skytale utilities and most common used types

[Wiki Documentation](https://gitlab.com/skytale-finance/skytale-commons/-/wikis/home)

## Sections

### Abi Decoder

Utility for decoding raw input from EVM transactions.

It can be used either as a stand-alone instance or as pool of instances for heavy use.

Implementation based on npm package [abi-decoder](https://www.npmjs.com/package/abi-decoder) 

#### environment variables

|Name|Description|Required|default|
|---|---|:---:|---|
|`MAX_NUMBER_OF_DECODER_INSTANCES`| max number of instances in pool of ABI Decoder | `false` | 10 | 
|`MIN_NUMBER_OF_DECODER_INSTANCES`| min number of instances in pool of ABI Decoder | `fakse` | 2 |

### Covalent

Access to the main Covalent API functions.

[Covalent API Documetation](https://www.covalenthq.com/docs/api)

Implemented:

* **Class A Endpoints**
  * **Balances**
    * [Get token balances for address](https://www.covalenthq.com/docs/api/#/0/Get%20token%20balances%20for%20address/USD/1)
    * [Get historical portfolio value over time](https://www.covalenthq.com/docs/api/#/0/Get%20historical%20portfolio%20value%20over%20time/USD/1)
  * **Transactions**
    * [Get transactions for address](https://www.covalenthq.com/docs/api/#/0/Get%20transactions%20for%20address/USD/1)
  * **Base**
    * [Get all chains](https://www.covalenthq.com/docs/api/#/0/Get%20all%20chains/USD/1)

#### environment variables

|Name|Description|Required|default|
|---|---|:---:|---|
|`COVALENT_URL`| covalent api url | `false` | https://api.covalenthq.com/v1 | 
|`COVALENT_API_KEY`| covalent api key | `true` | |


### Coingecko

Utilities' functions to access Coingecko price service and accessories.

It converts the chain ids and symbols in Coingecko internal identifiers.

[Coingecko API Documetation](https://www.coingecko.com/en/api/documentation)

#### environment variables

|Name|Description|Required|default|
|---|---|:---:|---|
|`COINGECKO_URL`| coingecko api url | `false` | https://api.coingecko.com/api/v3 | |

#### Usage

```shell
npm i skytale-commons
```

A few examples of usage:

* **Coingecko Data**

```typescript
import { getSupportedCurrenciesFromCache, getCoinListFromCache, getAssetPlatformsFromCache } from "skytale-commons";

// get the list of supported fiat currencies from 24h cache
const supportedCurrencies = await getSupportedCurrenciesFromCache();

// get the coin list from 24h cache 
const coins = await getCoinListFromCache();

// get the asset platforms list from 24h cache
const assets = await getAssetPlatformsFromCache()
```

```typescript
import { getCoinBySymbol, getCoinsBySymbols } from "skytale-commons";

// get a single coin from a symbol
const coin = await getCoinBySymbol("ETH");

// get an array of coins from an array of symbols
const coins = await getCoinsBySymbols(["ETH", "BNB"]);

// get a Coingecko Asset Id from a chain id
const id = getChainIdentifier(1);
```

* **Current prices**

```typescript
import { getPriceByTokenSymbol, getPriceByTokenAddress } from "skytale-commons";

const pricesBySymbol = await getPriceByTokenSymbol(
  ["ETH", "HEX"],
  ["USD", "EUR", "GBP"],
  {
    include_last_updated_at: true,
    include_24hr_change: true,
    include_24hr_vol: true,
    include_market_cap: true
  });

const pricesByTokenAddress = await getPriceByTokenAddress(
  1,
  ["0x2b591e99afE9f32eAA6214f7B7629768c40Eeb39","0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE"],
  ["USD", "EUR", "GBP"],
  {
    include_last_updated_at: true,
    include_24hr_change: true,
    include_24hr_vol: true,
    include_market_cap: true
  });

```

## Contributors

Skytale Commons is developed by the [Skytale team](https://skytale.finance/about-us/).

|||
|---|---|
|Joris Borsboom | @jorisborsboom |
|Patrik Csokas | @patricck |
|Avinash Buddana | @avinash.buddana1 |
|Martin Mali | @martinheti |
|Domnic Fernandes | @fdomnic8|
|Rhian Lewis | @rhianlewis | 
|Enrico Mariotti | @boulder225 |
|Massimiliano Gerardi | @massi.gerardi |

Any contribution will be appreciated.

---
_Source: https://npm.io/package/skytale-commons · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
