CosmJS

repository·main·Indexed 20 days ago

https://github.com/cosmos/cosmjs

A modular suite of TypeScript libraries for building JavaScript-based clients for the Cosmos ecosystem, including web apps, browser extensions, and server-side tools. The suite includes packages such as @cosmjs/stargate for Cosmos SDK interaction, @cosmjs/cosmwasm for smart contract interaction, @cosmjs/crypto for low-level cryptographic functionality, @cosmjs/encoding for Bech32 and Hex utilities, and @cosmjs/proto-signing for protobuf-based transaction signing.

Tokens
76.5K
Snippets
335
Records
396
Agent score
71%

What's inside CosmJS

  1. Overview of @cosmjs/encoding

    main

    The @cosmjs/encoding package is a utility library that extends standard JavaScript encoding capabilities. It is not tied to specific blockchain products and provides:

    • Hex, Base64, and ASCII encoding/decoding for Uint8Array.
    • Implementations that do not rely on the Node.js Buffer global, making it compatible with various environments.
    • Improved error messages for invalid input compared to standard methods.
  2. Overview of @cosmjs/utils

    main
    @cosmjs/utils provides utility functions that are independent of specific blockchain applications. While these functions are primarily designed for use in testing environments, some utilities like sleep are also useful for general runtime applications.
  3. Overview of CosmJS

    main
    CosmJS is a collection of JavaScript/TypeScript libraries designed for interacting with the Cosmos ecosystem. It supports a wide range of client solutions, including web applications, explorers, browser extensions, and server-side tools like faucets or scrapers. The project is developed in TypeScript and is designed to run in multiple environments.
  4. Overview of @cosmjs/crypto

    main
    @cosmjs/crypto provides low-level cryptographic functionality. It acts as a curated collection of external cryptographic libraries, enhanced with type safety, additional correctness checks, and a simplified API. While it is a core dependency for other @cosmjs libraries, it is designed to be used independently in any application.
  5. Use @cosmjs/tendermint-rpc for type-safe Tendermint RPC interactions

    main

    The @cosmjs/tendermint-rpc package provides a type-safe wrapper around the Tendermint RPC API. It simplifies interactions by handling data transformations automatically:

    • Binary Data: All binary data is passed in and out as Uint8Array.
    • Encoding/Decoding: The module manages hex and base64 encoding/decoding based on the specific field requirements and the version of Tendermint being used.
    • Numeric Conversion: It handles the conversion of numbers to and from strings as required by the RPC interface.
  6. How the Faucet HD wallet works

    main

    The faucet uses Hierarchical Deterministic (HD) paths to derive accounts from a single FAUCET_MNEMONIC.

    • Account 0: The primary token holder account.
    • Accounts 1 to FAUCET_CONCURRENCY: Distributor accounts used to manage funds.

    Common paths used by the faucet:

    • IOV: m/44'/234'/a'
    • Lisk: m/44'/134'/a'
    • Cosmos: m/44'/118'/0'/0/a

    Where a is the 0-based index of the account. You can access the token holder account using standard wallets (like Neuma) by providing the same mnemonic.

  7. Supported JS environments for CosmJS

    main

    CosmJS targets ES2020 and supports the following runtimes:

    1. Node.js 20+
    2. Modern browsers (Chromium, Firefox, Safari; excludes Internet Explorer and Edge Legacy).
    3. Browser extensions (Chromium, Firefox).

    Note: CosmJS uses WebAssembly (Wasm) for certain cryptographic functions. If your environment does not support Wasm, contact the maintainers for potential swappable implementations.