Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@cosmjs/stargate
Advanced tools
@cosmjs/stargate is a JavaScript library for interacting with Cosmos SDK-based blockchains. It provides tools for connecting to nodes, querying blockchain data, and creating and signing transactions.
Connecting to a Blockchain
This feature allows you to connect to a Cosmos SDK-based blockchain using an RPC endpoint. The code sample demonstrates how to establish a connection and retrieve the chain ID.
const { StargateClient } = require('@cosmjs/stargate');
async function connect() {
const rpcEndpoint = 'https://rpc.cosmos.network';
const client = await StargateClient.connect(rpcEndpoint);
console.log('Connected to chain:', await client.getChainId());
}
connect();
Querying Blockchain Data
This feature allows you to query blockchain data such as account information. The code sample demonstrates how to retrieve account data for a given address.
const { StargateClient } = require('@cosmjs/stargate');
async function queryAccount(address) {
const rpcEndpoint = 'https://rpc.cosmos.network';
const client = await StargateClient.connect(rpcEndpoint);
const account = await client.getAccount(address);
console.log('Account data:', account);
}
queryAccount('cosmos1...');
Creating and Signing Transactions
This feature allows you to create and sign transactions. The code sample demonstrates how to send tokens from one account to another, including setting up the wallet, connecting to the blockchain, and broadcasting the transaction.
const { DirectSecp256k1HdWallet } = require('@cosmjs/proto-signing');
const { assertIsBroadcastTxSuccess, SigningStargateClient } = require('@cosmjs/stargate');
async function sendTokens() {
const mnemonic = 'your mnemonic here';
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic);
const [firstAccount] = await wallet.getAccounts();
const rpcEndpoint = 'https://rpc.cosmos.network';
const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, wallet);
const amountFinal = {
denom: 'uatom',
amount: '1000',
};
const fee = {
amount: [{ denom: 'uatom', amount: '500' }],
gas: '200000',
};
const result = await client.sendTokens(firstAccount.address, 'cosmos1...', [amountFinal], fee, 'Test transaction');
assertIsBroadcastTxSuccess(result);
console.log('Transaction successful:', result);
}
sendTokens();
@cosmjs/launchpad is another library for interacting with Cosmos SDK-based blockchains, but it is designed for the older Cosmos SDK versions (pre-Stargate). It provides similar functionalities such as connecting to nodes, querying data, and signing transactions, but it is not compatible with the latest Stargate features.
cosmjs-types is a library that provides TypeScript definitions for Cosmos SDK protobuf messages. It is useful for developers who need to work with raw protobuf messages and want type safety in their applications. While it does not provide high-level functionalities like @cosmjs/stargate, it complements it by offering low-level message handling.
cosmos-client is a JavaScript library for interacting with Cosmos SDK-based blockchains. It offers similar functionalities to @cosmjs/stargate, such as connecting to nodes, querying data, and signing transactions. However, it may not be as actively maintained or feature-rich as @cosmjs/stargate.
A client library for the Cosmos SDK 0.40.
CosmJS version | Supported Cosmos SDK version(s) |
---|---|
^0.26.0 | 0.42.x |
^0.25.0 | 0.42.x |
^0.24.0 | 0.40.x, 0.41.x, 0.42.x |
^0.24.0-alpha.14 | 0.40.0 |
^0.24.0-alpha.8 | 0.40.0-rc3 |
0.24.0-alpha.2 – 0.24.0-alpha.7 | 0.40.0-rc2 |
0.24.0-alpha.1 | 0.40.0-rc1 |
This package is part of the cosmjs repository, licensed under the Apache License 2.0 (see NOTICE and LICENSE).
FAQs
Utilities for Cosmos SDK 0.40
The npm package @cosmjs/stargate receives a total of 96,288 weekly downloads. As such, @cosmjs/stargate popularity was classified as popular.
We found that @cosmjs/stargate demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.