npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@d11k-ts/hermes

v0.1.5

Published

hermes module for d11k chain

Downloads

6

Readme

@d11k-ts/hermes

Hermes Module for Dojima chain

Installation

yarn add @d11k-ts/hermes

Following dependencies have to be installed into your project. These are not included in @d11k-ts/hermes.

yarn add axios @cosmos-client/core@^0.45.13 bech32-buffer@^0.2.1

NOTE: Make sure to install same version of @cosmos-client/core and bech32-buffer as @d11k-ts/cosmos is using ( currently "@cosmos-client/core": "^0.45.13", "bech32-buffer": "^0.2.1"). In other case things might break.

Service Providers

This package uses the following service providers:

| Network | Node | RPC | |---------|-------------------------------------|-------------------------------------| | Testnet | https://api-test.h4s.dojima.network | https://rpc-test.h4s.dojima.network | | Mainnet | NA | NA |

Note : 'Mainnet' is currently under process. Not applicable yet.

| Function | Service | Notes | | --------------------------- | -------------- | ------------------------------------------------------------------- | | Balances | Cosmos RPC | https://cosmos.network/rpc/v0.37.9 (GET /bank/balances/{address}) | | Transaction history | Tendermint RPC | https://docs.tendermint.com/master/rpc/#/Info/tx_search | | Transaction details by hash | Cosmos RPC | https://cosmos.network/rpc/v0.37.9 (GET /txs/{hash}) | | Transaction broadcast | Cosmos RPC | https://cosmos.network/rpc/v0.37.9 (POST /txs) |

Rate limits: No

Documentation: Basic usage example

Connect wallet to new Hermes Client

  • Create new HermesChain client
  • Network default is Mainnet

// Imports 
import {Network} from '@d11k-ts/client'
import {DOJ_DECIMAL, HermesClient} from '@d11k-ts/hermes'
import {AssetDOJNative, assetAmount, assetToBase, baseToAsset} from '@d11k-ts/utils'


// Create new instance of the client and query chain for balances. 
const connectWallet = async () => {

  let phrase = "phrase"
  // mainnet
  const hermesClient = new HermesClient({phrase})
  // testnet
  // const hermesClient = new HermesClient({ phrase, network: Network.DojTestnet })

  let address = hermesClient.getAddress()
  console.log(`Address: ${address}`)
  try {
    const balance = await hermesClient.getBalance(address, [AssetDOJNative])
    let assetAmount = (baseToAsset(balance[0].amount)).amount()
    console.log(`With balance: ${assetAmount}`)
  } catch (error) {
    console.log(`Caught ${error}`)
  }
}

Transfer doj using Hermes Client

  • Default feeRate is fast
  • Create new HermesChain client instance
  • Convert amount to transfer to base amount
  • Build transaction
  • Returns txHash as string
const transferDoj = async () => {

  // First initiate HermesClient
  let amountToTransfer = 0.1
  let amount = assetToBase(assetAmount(amountToTransfer, DOJ_DECIMAL))
  let recipient = "insert address"
  try {
    const txid = await hermesClient.transfer({
      "amount": amount,
      "recipient": recipient,
      "memo": "test",             // optional
      "asset": AssetDOJNative,    // optional (default)
      "walletIndex": 0            // optional (default)
    })
    console.log(`Transaction sent: ${txid}`)
  } catch (error) {
    console.log(`Caught ${error}`)
  }
}

Get transaction Data & transaction History

  • Create new HermesClient instance
  • Call getTransactionData(hash) returns hash-details
  • Call getTransactions(address) returns list of transactions (if any)

const transactionData = async () => {

  // First initiate HermesClient
  let hash = "insert hash"
  let address = hermesClient.getAddress()
  try {
    const txData = await hermesClient.getTransactionData(hash, address)
    console.log(txData)
  } catch (error) {
    console.log(`Caught ${error}`)
  }
}
// By default getTransactions() returns the transactions for the current address
// Optional param - any dojima address
const transactionHistory = async () => {
  try {
    const txHistory = await hermesClient.getTransactions(address)
    console.log(`Found ${txHistory.total}`)
    txHistory.txs.forEach(tx => console.log(tx.hash))
  } catch (error) {
    console.log(`Caught ${error}`)
  }
}

Get transfer Fees

  • Hermeschain runs on fee type of Flatfee set to 0.02 DOJ
// Returns Fees Fast: 0.02 Fastest: 0.02 Average: 0.02
const fee = async () => {

  // First initiate HermesClient
  try {
    const {fast, fastest, average} = await hermesClient.getFees()
    console.log(`Fees Fast: ${baseToAsset(fast).amount()} Fastest: ${baseToAsset(fastest).amount()} Average: ${baseToAsset(average).amount()}`)
  } catch (error) {
    console.log(`Caught ${error}`)
  }
}

Deposit doj using Hermes Client

  • Create new HermesChain client instance
  • Convert amount to transfer to base amount
  • Deposit transaction
  • Returns txHash as string
import {SwapAssetList} from '@d11k-ts/utils'

const transferDoj = async () => {

  // First initiate HermesClient
  let amountToTransfer = 0.1
  let amount = assetToBase(assetAmount(amountToTransfer, DOJ_DECIMAL))
  // amount: number     Note: convert amount to 'BaseAmount' before passing to transfer function
  // memo: string
  'ADD:{SwapAssetList}:{respective-token-address}'
  'SWAP:{SwapAssetList}:{receiver-token-address}'
  try {
    // 'memo' with ADD
    const txid = await hermesClient.deposit({
      amount,
      memo: `ADD:{SwapAssetList}:{respective-token-address}`,
    })
    // 'memo' with SWAP
    // const depositHash = await hermesClient.deposit({
    //   amount,
    //   memo: `SWAP:{SwapAssetList}:{receiver-token-address}`,
    // })
    console.log(`Deposit tx hash: ${txid}`)
  } catch (error) {
    console.log(`Caught ${error}`)
  }
}

Example Code

For sample code check out example test case in ./examples/test.ts