Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@talismn/chaindata-js

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@talismn/chaindata-js

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

latest
Source
npmnpm
Version
0.0.7
Version published
Maintainers
3
Created
Source

📁 Chaindata JS Wrapper

This repository is a JS helper library for the @talismn/chaindata repository, enabling easy fetching of assets and config files for developers when building within the polkadot ecosystem.

The goals of this repo are:

  • Allow developers to easily use the @talismn/chaindata repository in applications
  • 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

yarn add @talismn/chaindata-js

Importing

import chaindata from 'chaindata'

Discover chains

Discover which chains are available

const chains = await chaindata.chains()

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

{
  "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).

const chain = await chaindata.chain(0)

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

{
  "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

const name = chain.name

Which returns the value requested, i.e:

Polkadot

Fetch chain assets

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

const logo = chain.asset.logo

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

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

And can be used in an img tag:

<img src={logo}/>

Notes

  • The main chain config and chain details are fetched on the fly, as requested, and cached locally for the session

FAQs

Package last updated on 05 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts