@sudophunk/unchained-client
TypeScript icon, indicating that this package has built-in type declarations

10.14.0 • Public • Published

@shapeshiftoss/unchained-client

Provides a TypeScript axios client to interact with all supported unchained APIs.

Installing

Using npm:

npm install @shapeshiftoss/unchained-client

Using yarn:

yarn add @shapeshiftoss/unchained-client

Resources

  • CAIP-2 naming conventions used for chainId
  • CAIP-19 naming conventions used for assetId

Usage

import * as unchained from '@shapeshiftoss/unchained-client'

const address = 'cosmos1t5u0jfg3ljsjrh2m9e47d4ny2hea7eehxrzdgd'

// configuration for the api client
const config = new unchained.cosmos.Configuration({ basePath: 'https://dev-api.cosmos.shapeshift.com' })

// create new instance of the api client
const apiClient = new unchained.cosmos.V1Api(config)

// create new instance of the ws client
const wsClient = new unchained.ws.Client<unchained.cosmos.Tx>('wss://dev-api.cosmos.shapeshift.com')

// create new instance of the transaction parser
// chainId is in the format of [Caip2](https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md)
const parser = new unchained.cosmos.TransactionParser({ chainId: 'cosmos:cosmoshub-4' })

// example api client request
const { data } = await apiClient.getBalance({ pubkey: address })

// example websocket subscription for new transaction and transaction parsing
await this.providers.ws.subscribeTxs(
  'test',
  { topic: 'txs', addresses: [address] },
  async (msg) => {
        const tx = await parser.parse(msg.data, msg.address)
  },
  (err) => console.warn(err)
)

Readme

Keywords

none

Package Sidebar

Install

npm i @sudophunk/unchained-client

Weekly Downloads

0

Version

10.14.0

License

MIT

Unpacked Size

2.64 MB

Total Files

1220

Last publish

Collaborators

  • sudophunk