Socket
Book a DemoInstallSign in
Socket

@talismn/api

Package Overview
Dependencies
Maintainers
4
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@talismn/api

A lib for spinning up multiple polkadot.js or lightclient instances and being able to perform aggregate queries

0.0.23
latest
Source
npmnpm
Version published
Weekly downloads
8
166.67%
Maintainers
4
Weekly downloads
 
Created
Source

@talismn/api

Talisman

license npm-version npm-downloads discord-link

A package for doing fast analysis across multiple DotSama chains at once.

At a high level, @talismn/api is a factory library which you can use to perform queries across many DotSama parachains. These queries are executed in parallel and their results are combined into a useful output.

This library can be made to fetch data via one of three connector types:

  • TalismanConnect - our super lightweight RPC client designed to query potentially hundreds of parachains as fast and efficiently as possible ⚡
  • PolkadotJs - the full featured RPC client from @paritytech
  • [TODO] Lightclient - spin up a (light) node and talk straight to the parachain networks

By default this library uses the community-defined chain RPCs and lightclient chainspecs at TalismanSociety/chaindata, but can also be used with custom RPCs/chainspecs if needed.

The goals of this library are to:

  • Allow developers to perform the same action across multiple chains (e.g. get account balances)
  • Allow developers to discover chain capabilities (i.e. what pallets they may have)
  • Provide developers with easy access to often-sought data located across multiple chains (all the balances!)

In the future, we would like to:

  • Add parachain pallet discovery and introspection
  • Add more aggregated information endpoints to accompany the balances endpoint (e.g. crowdloans, crowdloan contributions, bonded funds, etc)
  • Decouple incoming calls to balances/subscribeBalances from outgoing RPC requests (add a cache which is shared between api calls, use RPC to fill cache rather than to directly respond to api request)

Usage

Please note: while we work towards a v1.0 release, the public interface is subject to change.

Import api

import Talisman from '@talismn/api'

note: Talisman is a singleton

Make a one-off call to balances

// Connect to the chain RPCs
await Talisman.connect({ chains: [0, 2, 2000] })

// Fetch balances
await Talisman.balances(['0x000...', '0x000...'])

// Will output an array of balances:
//
// [{
//   chainId: '0',
//   address: '0x000...',
//   token: 'DOT',
//
//   total: '10000000000000',
//   free: '10000000000000',
//   reserved: '0',
//   miscFrozen: '0',
//   feeFrozen: '0',
// }]

note: Talisman.connect is only required if not using subscriptions

Subscribe to balances

// Initialize the singleton
Talisman.init()

// Subscribe to balances
const unsubscribe = Talisman.subscribeBalances(
  [0, 2, 2000], // chains
  ['0x000...', '0x000...'], // addresses
  (balance) => console.log(balance)
)

// Will output all account balanaces once, then future balance changes as they happen:
//
// {
//   chainId: '0',
//   address: '0x000...',
//   token: 'DOT',
//
//   total: '10000000000000',
//   free: '10000000000000',
//   reserved: '0',
//   miscFrozen: '0',
//   feeFrozen: '0',
// }

// (later) Unsubscribe from future balances
unsubscribe()

Keywords

talisman

FAQs

Package last updated on 23 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.