Socket
Socket
Sign inDemoInstall

@cosmjs/tendermint-rpc

Package Overview
Dependencies
Maintainers
2
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cosmjs/tendermint-rpc

Tendermint RPC clients


Version published
Weekly downloads
148K
decreased by-1.84%
Maintainers
2
Weekly downloads
 
Created

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

FAQs

Package last updated on 21 Jun 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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc