@cosmonauts/cosmjs
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Cosmjs

Wrapper of @cosmonauts/auth and @cosmonauts/cosmos to fit corresponding interfaces in @cosmjs

Usage

npm install @cosmonauts/cosmjs

To sign messages (taking stargate signing client as example)

// import * from "@cosmonauts/cosmjs"; // Error: use sub-imports, to ensure small app size
import { StargateSigningClient } from "@cosmonauts/cosmjs/stargate";

const client = StargateSigningClient.connectWithSigner(<rpc-endpoint>, <offline signer>);
const result = await client.signAndBroadcast(<address>, <messages>, "auto");
console.log(result.transactionHash); // the hash of TxRaw

To construct an offline signer (taking direct signer as example)

import { Secp256k1Wallet } from "@cosmonauts/cosmjs/wallets/secp256k1";

const wallet = Secp256k1Wallet.fromMnemonic("<mnemonic-words>", { prefix: "<prefix>" });
const directOfflineSigner = wallet.toOfflineDirectSigner();

To make queries

import { RpcQuery } from "@cosmonauts/cosmjs/query/rpc";

const rpcQuery = new RpcQuery(chain.osmosis.rpc);
const { validators } = await rpcQuery.validators({
    status: bondStatusToJSON(BondStatus.BOND_STATUS_BONDED),
});

Implementations

  • signing client
    • signing client from @cosmonauts/cosmjs/signing-client
    • stargate signing client from @cosmonauts/cosmjs/stargate
    • cosmwasm signing client from @cosmonauts/cosmjs/cosmwasm-stargate
  • wallet
    • secp256k1 wallet from @cosmonauts/cosmjs/wallets/secp256k1
  • query
    • rpc query client from @cosmonauts/cosmjs/query/rpc

License

MIT License (MIT) & Apache License

Copyright (c) 2024 Cosmology (https://cosmology.zone/)

Package Sidebar

Install

npm i @cosmonauts/cosmjs

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

103 kB

Total Files

52

Last publish

Collaborators

  • zetazz
  • ljun
  • pyramation