# @talismn/chaindata-js

> A JS indexing and lookup lib for easily fetching information from the @talismn/chaindata repo.

Latest version **0.0.7** (published 2021-11-05) · GPL-3.0-only license · 0 weekly downloads

## Install

```sh
npm install @talismn/chaindata-js
pnpm add @talismn/chaindata-js
yarn add @talismn/chaindata-js
bun add @talismn/chaindata-js
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2021-11-05 |
| First published | 2021-08-11 |
| Weekly downloads | 0 |
| License | GPL-3.0-only |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 51.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Talisman Devs <devs@talisman.community> |
| Maintainers | alectalisman, midnightswami, talisman.community |

## Links

- npm: https://www.npmjs.com/package/@talismn/chaindata-js
- Repository: https://github.com/TalismanSociety/chaindata-js.git
- Homepage: https://talisman.community
- Issues: https://github.com/TalismanSociety/chaindata-js/issues
- npm.io page: https://npm.io/package/@talismn/chaindata-js

## Recent versions

- 0.0.7 (latest) — 2021-11-05
- 0.0.6 — 2021-11-04
- 0.0.5 — 2021-10-06
- 0.0.4 — 2021-10-06
- 0.0.3 — 2021-08-12
- 0.0.2 — 2021-08-12
- 0.0.1 — 2021-08-11

## README

# 📁 Chaindata JS Wrapper
This repository is a JS helper library for the [@talismn/chaindata](https://github.com/talismansociety/chaindata) repository, enabling easy fetching of assets and config files for developers when building within the polkadot ecosystem.

The goals of this repo are:

1. Allow developers to easily use the @talismn/chaindata repository in applications
2. Allow developers to discover availability of chains & chains assets

>Note: This repoository is in development and may contain bugs and change without warning. Use at your own discretion.

----

## Usage

#### Installation

```bash
yarn add @talismn/chaindata-js
```

#### Importing

```bash
import chaindata from 'chaindata'
```

### Discover chains
Discover which chains are available

```js
const chains = await chaindata.chains()
```

The returned object contains key:value pairs of all available <b>chain ids</b> and <b>names</b>.

```json5
{
  "0": "Polkadot",
  "2": "Kusama",
  // ... etc
}
```

### Load a chain by ID
Fetch a chains by ID and load all relevant information. In this instance Polkadot (id: 0).

```js
const chain = await chaindata.chain(0)
```

The returned object contains all relevant information about the requested chain.

```json5
{
  "id": "0",
  "name": "Polkadot",
  "description": "Polkadot is a heterogeneous multichain with shared security and interoperability",
  "isRelay": true,
  "links":{
    "Website": "https://polkadot.network",
    "Twitter": "https://twitter.com/Polkadot",
    "Support": "https://support.polkadot.network/support/home",
    "Discord": "https://discord.com/invite/wGUDt2p",
    "Github": "https://github.com/paritytech/polkadot"
  },
  "assets":{
    "logo": "logo.svg",
    "banner": "banner.png",
    "card": "card.png"
  },
  "rpcs": [
    "wss://rpc.polkadot.io"
  ],
  "status": "READY",
}
```

### Fetch chain details
To access any fields on the chains, using the instance above

```js
const name = chain.name
```

Which returns the value requested, i.e:

```text
Polkadot
```

### Fetch chain assets
To access any assets on the chain, using the instance above:

```js
const logo = chain.asset.logo
```

Which returns a string as the full path to the asset file.

```string
https://raw.githubusercontent.com/TalismanSociety/chaindata/master/0/assets/logo.svg
```

And can be used in an img tag:

```html
<img src={logo}/>
```

----

## Notes
1. The main chain config and chain details are fetched on the fly, as requested, and cached locally for the session

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