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

@injectivelabs/tx-ts

v1.0.43

Published

Utilities for creating transactions for Injective

Downloads

191

Readme

🌟 Injective Protocol - TX TS

downloads npm-version license

Accessing decentralized finance through TypeScript (for Web and Node environment)

@injectivelabs/tx-ts is a TypeScript package for generating transactions from Messages easily that can be broadcasted to Injective. It also provides broadcasting clients that broadcast the transaction to Injective.

📚 Installation

yarn add @injectivelabs/tx-ts

📖 Documentation

There are three pieces of the tx-ts - generating a transaction, broadcasting a transactions and utility functions that can be performed on a transaction.

Generating a transaction

To generate a transaction that can be broadcasted to Injective, you can use the createTransaction function from the @injectivelabs/tx-ts package. Here is its definition and the params it receives / result it gives so its easier to understand:

export function createTransaction = (args: CreateTransactionArgs): CreateTransactionResult

/** @type {CreateTransactionArgs} */
export interface CreateTransactionArgs {
  message: MsgArg | MsgArg[] // the message that should be packed into the transaction
  memo: string // the memo to include in the transaction
  fee: StdFee // the fee to include in the transaction
  pubKey: string // the pubKey of the signer of the transaction in base64
  sequence: number // the sequence (nonce) of the signer of the transaction
  accountNumber: number // the account number of the signer of the transaction
  chainId: string // the chain id of the chain that the transaction is going to be broadcasted to
}

/** @type {CreateTransactionResult} */
export interface CreateTransactionResult {
  txRaw: TxRaw // the Tx raw that was created
  signDoc: SignDoc // the SignDoc that was created - used for signing of the transaction
  accountNumber: number // the account number of the signer of the transaction
  bodyBytes: Uint8Array // the body bytes of the transaction
  authInfoBytes: Uint8Array // the auth info bytes of the transaction
  signBytes: Uint8Array // the sign bytes of the transaction (SignDoc serialized to binary)
  signHashedBytes: Uint8Array // the sign bytes of the transaction (SignDoc serialized to binary) and hashed using keccak256
}

After the transaction is created, usually the signBytes of the result is getting signed and the signature gets appended on the txRaw that is also returned from the createTransaction function. Then, the txRaw is broadcasted to the Injective chain.

Broadcasting a transaction

There are two ways to broadcast a transaction to the Injective chain. First, as mentioned above we need to get the txRaw transaction (with added signatures) and use one of the two available clients exported from this package:

  • TxGrpcClient (which broadcast the transaction using the gRPC protocol), the endpoint passed to the constructor should be the sentryGrpcEndpoint
  • TxRestClient (which broadcast the transaction using the REST protocol), the endpoint passed to the constructor should be the sentryHttpEndpoint

There are pre-defined endpoints for different environments that can be found in the @injectivelabs/networks package.

Also, both of the clients have a simulate method which simulates the transaction before executing it on the chain.


⛑ Support

Reach out to us at one of the following places!

  • Website at injective.com
  • Twitter at @Injective
  • Discord at Discord
  • Telegram at Telegram

🔓 License

This software is licensed under the MIT license. See LICENSE for full disclosure.