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

@jatindersngh116/evmos-ts-wallet

v0.1.1

Published

Streakk ts/js wallet to sign and broadcast messages created with evmosjs

Downloads

2

Readme

STREAKK TS Wallet

STREAKK ts/js wallet to sign and broadcast messages created with streakk

Usage

yarn add @hanchon/evmos-ts-wallet

Some constants are exported as helpers but the values may not be updated for the current state of the network:

  • MAINNET_FEE
  • TESTNET_FEE
  • LOCALNET_FEE
  • MAINNET_CHAIN
  • TESTNET_CHAIN
  • LOCALNET_CHAIN

Configuration

The constants for fee and chain should be updated by the user to follow the network upgrade and the fee changes, I'll try to keep it up to date, but probably you want to control this values in your code.

Both getSender and brodcast should set the option parameter called url, this should be pointing to the port 1317 of your node or a public rest endpoint. By default is using localhost:1317.

Both signing functions have the optional parameter broadcastMode that by default is BROADCAST_MODE_BLOCK.

Example using keplr signature

import { Wallet } from '@ethersproject/wallet'
import { createMessageSend } from '@tharsis/transactions'
import {
  broadcast,
  getSender,
  LOCALNET_CHAIN,
  LOCALNET_FEE,
  signTransaction,
} from '@hanchon/evmos-ts-wallet'
;(async () => {
  const privateMnemonic =
    'pluck view carry maid bamboo river major where dutch wood certain oval order wise awkward clerk adult summer because number raven coil crunch hat'
  const wallet = Wallet.fromMnemonic(privateMnemonic)

  const sender = await getSender(wallet)
  const txSimple = createMessageSend(LOCALNET_CHAIN, sender, LOCALNET_FEE, '', {
    destinationAddress: 'streakk1pmk2r32ssqwps42y3c9d4clqlca403yd9wymgr',
    amount: '1',
    denom: 'tSTKC',
  })

  const resKeplr = await signTransaction(wallet, txSimple)
  const broadcastRes = await broadcast(resKeplr)
  if (broadcastRes.tx_response.code === 0) {
    console.log('Success')
  } else {
    console.log('Error')
  }
})()

Example using eip712

import { Wallet } from '@ethersproject/wallet'
import { createMessageSend } from '@tharsis/transactions'
import {
  broadcast,
  getSender,
  LOCALNET_CHAIN,
  LOCALNET_FEE,
  signTransactionUsingEIP712,
} from '@hanchon/evmos-ts-wallet'
;(async () => {
  const privateMnemonic =
    'pluck view carry maid bamboo river major where dutch wood certain oval order wise awkward clerk adult summer because number raven coil crunch hat'
  const wallet = Wallet.fromMnemonic(privateMnemonic)
  const sender = await getSender(wallet)

  const txSimple = createMessageSend(LOCALNET_CHAIN, sender, LOCALNET_FEE, '', {
    destinationAddress: 'streakk1pmk2r32ssqwps42y3c9d4clqlca403yd9wymgr',
    amount: '1',
    denom: 'tSTKC',
  })

  const resMM = await signTransactionUsingEIP712(
    wallet,
    sender.accountAddress,
    txSimple,
  )

  const broadcastRes = await broadcast(resMM)
  if (broadcastRes.tx_response.code === 0) {
    console.log('Success')
  } else {
    console.log('Error')
  }
})()

NOTE

  • If your wallet didn't get any transaction, it won't be registered in the blockchain and the getSender function will throw an error.
  • The getSender function should be called before sending each transaction to update the nonce or manually increment the value in the sender object.

Dependencies

  • @ethersproject
  • @metamask/eth-sig-util
  • @tharsis/proto
  • @tharsis/transactions
  • node-fetch (using v2 that is limited but should work without enforcing ESM. In src/helper.ts there is a basic implementation of fetch and post that can be used to replace node-fetch, in case that lib is not working for your case)