Socket
Socket
Sign inDemoInstall

@cosmjs/tendermint-rpc

Package Overview
Dependencies
10
Maintainers
2
Versions
105
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cosmjs/tendermint-rpc

Tendermint RPC clients


Version published
Weekly downloads
149K
increased by19.47%
Maintainers
2
Created
Weekly downloads
 

Package description

What is @cosmjs/tendermint-rpc?

@cosmjs/tendermint-rpc is an npm package that provides a client for interacting with Tendermint-based blockchains. It allows developers to query blockchain data, subscribe to events, and broadcast transactions using Tendermint's RPC protocol.

What are @cosmjs/tendermint-rpc's main functionalities?

Querying Blockchain Data

This feature allows you to query various pieces of information from the blockchain, such as the current status, block information, and more. The code sample demonstrates how to connect to a Tendermint node and fetch its status.

const { Tendermint34Client } = require('@cosmjs/tendermint-rpc');

async function queryBlockchain() {
  const client = await Tendermint34Client.connect('http://localhost:26657');
  const status = await client.status();
  console.log(status);
}

queryBlockchain();

Subscribing to Events

This feature allows you to subscribe to various events happening on the blockchain, such as new blocks being created. The code sample demonstrates how to subscribe to new block events and handle them.

const { Tendermint34Client, SubscriptionEventType } = require('@cosmjs/tendermint-rpc');

async function subscribeToEvents() {
  const client = await Tendermint34Client.connect('http://localhost:26657');
  const subscription = client.subscribe({
    query: 'tm.event = "NewBlock"'
  });

  subscription.addListener(SubscriptionEventType.NewBlock, (event) => {
    console.log('New block event:', event);
  });
}

subscribeToEvents();

Broadcasting Transactions

This feature allows you to broadcast transactions to the blockchain. The code sample demonstrates how to connect to a Tendermint node and broadcast a sample transaction.

const { Tendermint34Client } = require('@cosmjs/tendermint-rpc');

async function broadcastTransaction(tx) {
  const client = await Tendermint34Client.connect('http://localhost:26657');
  const result = await client.broadcastTxCommit({ tx });
  console.log(result);
}

const sampleTx = new Uint8Array([0x00, 0x01, 0x02]);
broadcastTransaction(sampleTx);

Other packages similar to @cosmjs/tendermint-rpc

Readme

Source

@cosmjs/tendermint-rpc

npm version

This package provides a type-safe wrapper around Tendermint RPC. Notably, all binary data is passed in and out as Uint8Array, and this module is reponsible for the hex/base64 encoding/decoding depending on the field and version of Tendermint. Also handles converting numbers to and from strings.

License

This package is part of the cosmjs repository, licensed under the Apache License 2.0 (see NOTICE and LICENSE).

FAQs

Last updated on 18 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc