### Install and Run CosmJs Examples Source: https://github.com/atmoner/cosmjs-examples/blob/main/README.md This snippet shows how to clone the repository, install dependencies using yarn, and start the development server for the documentation. ```bash git clone https://github.com/atmoner/cosmjs-examples.git cd cosmjs-examples yarn yarn docs:dev ``` -------------------------------- ### Install CosmJs Packages Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/README.md Installs the necessary CosmJs packages for stargate and proto-signing using either yarn or npm. ```bash yarn add @cosmjs/stargate @cosmjs/proto-signing ``` ```bash npm install @cosmjs/stargate @cosmjs/proto-signing ``` -------------------------------- ### Connect to RPC and Query Staking Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/staking/QueryDelegatorUnbondingDelegationsRequest.md Establishes a connection to a Tendermint RPC endpoint using Tendermint37Client, creates a QueryClient and ProtobufRpcClient, and initializes the staking query client from cosmjs-types. This setup is necessary for making subsequent queries to the staking module. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as staking from "cosmjs-types/cosmos/staking/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querystaking = new staking.QueryClientImpl(rpcClient) ``` -------------------------------- ### Connect to RPC and Query Distribution Params Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/distribution/QueryParamsRequest.md Establishes a connection to a Tendermint RPC endpoint, creates a QueryClient and ProtobufRpcClient, and then instantiates a distribution query client to fetch parameters. This example requires @cosmjs/stargate and cosmjs-types. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as distribution from "cosmjs-types/cosmos/distribution/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querydistribution = new distribution.QueryClientImpl(rpcClient) let Params = await querydistribution.Params({}) console.log(Params) ``` -------------------------------- ### Connect to Tendermint RPC and Query Governance Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/gov/QueryDepositsRequest.md Establishes a connection to a Tendermint RPC endpoint, creates a QueryClient and ProtobufRpcClient, and initializes a governance query client. This setup is necessary for making subsequent queries to the blockchain. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as gov from "cosmjs-types/cosmos/gov/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querygov = new gov.QueryClientImpl(rpcClient) ``` -------------------------------- ### Connect to Tendermint RPC and Query Staking Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/staking/QueryValidatorUnbondingDelegationsRequest.md Establishes a connection to a Tendermint RPC endpoint using Tendermint37Client, creates a QueryClient and ProtobufRpcClient, and initializes a staking query client from cosmjs-types. This setup is necessary for making subsequent queries to the blockchain. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as staking from "cosmjs-types/cosmos/staking/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querystaking = new staking.QueryClientImpl(rpcClient) ``` -------------------------------- ### Connect to RPC and Query Community Pool Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/distribution/QueryCommunityPoolRequest.md Establishes a connection to a Tendermint RPC endpoint, creates a query client, and then queries the community pool. This example demonstrates the basic setup for interacting with the Cosmos SDK distribution module. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as distribution from "cosmjs-types/cosmos/distribution/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querydistribution = new distribution.QueryClientImpl(rpcClient) let CommunityPool = await querydistribution.CommunityPool({}) console.log(CommunityPool) ``` -------------------------------- ### Install @cosmjs/stargate with Yarn or npm Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/stargate/README.md Installs the @cosmjs/stargate library using either the Yarn or npm package manager. This is the first step to using the library in your project. ```bash yarn add @cosmjs/stargate ``` ```bash npm install @cosmjs/stargate ``` -------------------------------- ### Connect to Tendermint RPC and Query Groups Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/group/QueryGroupsByMemberRequest.md Establishes a connection to a Tendermint RPC endpoint using `@cosmjs/tendermint-rpc` and `@cosmjs/stargate`. It then initializes a query client and a gRPC client to interact with the Cosmos SDK's group module. This setup is necessary for making subsequent queries, such as fetching groups by member. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as group from "cosmjs-types/cosmos/group/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querygroup = new group.QueryClientImpl(rpcClient) ``` -------------------------------- ### Connect to Tendermint RPC and Query Authz Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/authz/QueryGranteeGrantsRequest.md Establishes a connection to a Tendermint RPC endpoint using Tendermint37Client, creates a QueryClient and ProtobufRpcClient, and initializes the Authz QueryClientImpl. This setup is necessary for making authenticated queries to the Cosmos SDK chain. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as authz from "cosmjs-types/cosmos/authz/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const queryauthz = new authz.QueryClientImpl(rpcClient) ``` -------------------------------- ### Connect to RPC and Query Staking Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/staking/QueryDelegationRequest.md Establishes a connection to a Tendermint RPC endpoint using Tendermint37Client, creates a QueryClient and ProtobufRpcClient, and initializes a staking query client. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as staking from "cosmjs-types/cosmos/staking/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querystaking = new staking.QueryClientImpl(rpcClient) ``` -------------------------------- ### Connect to RPC and Query Staking Params Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/staking/QueryParamsRequest.md Establishes a connection to a Tendermint RPC endpoint and initializes a query client for staking parameters. It then demonstrates how to fetch the staking parameters. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as staking from "cosmjs-types/cosmos/staking/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querystaking = new staking.QueryClientImpl(rpcClient) let Params = await querystaking.Params({}) console.log(Params) ``` -------------------------------- ### Connect to RPC and Query Groups Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/group/QueryGroupsRequest.md Establishes a connection to a Tendermint RPC endpoint, creates a query client, and initializes a query client for the Cosmos group module. It then demonstrates how to fetch all groups. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as group from "cosmjs-types/cosmos/group/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querygroup = new group.QueryClientImpl(rpcClient) let Groups = await querygroup.Groups({}) console.log(Groups) ``` -------------------------------- ### Slide Transition Example Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/slides.md Illustrates setting slide transition effects using the 'data-transition' attribute. ```html ## Transition Transition can be changed by setting the `transition` config option globally or `data-transition` attribute on slide. Possible values: - none - fade - slide - convex - concave - zoom ``` -------------------------------- ### Basic Slide Structure Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/slides.md Demonstrates the fundamental structure for creating slides, including title, icon, and layout. It also shows how to start a slide presentation. ```markdown --- icon: person-chalkboard layout: Slide --- @slidestart ``` -------------------------------- ### Connect to RPC and Query CosmWasm Code Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/cosmwasm/query/QueryCodeRequest.md Connects to a Tendermint RPC endpoint using `@cosmjs/tendermint-rpc` and `@cosmjs/stargate`. It then initializes a CosmWasm query client to retrieve code information using `cosmjs-types`. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as cosmwasm from "cosmjs-types/cosmwasm/wasm/v1/query.js" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querywasm = new cosmwasm.QueryClientImpl(rpcClient) let Code = await querywasm.Code({ "codeId": "0" }) console.log(Code) ``` -------------------------------- ### Connect to RPC and Initialize FeeGrant Query Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/feegrant/QueryAllowanceRequest.md Establishes a connection to a Tendermint RPC endpoint and initializes a QueryClient and a feegrant QueryClientImpl. This setup is necessary for querying fee grant information. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as feegrant from "cosmjs-types/cosmos/feegrant/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const queryfeegrant = new feegrant.QueryClientImpl(rpcClient) ``` -------------------------------- ### Connect to RPC and Query Votes Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/gov/QueryVotesRequest.md Establishes a connection to a Tendermint RPC endpoint using `@cosmjs/tendermint-rpc` and `@cosmjs/stargate`. It then demonstrates how to query for votes on a specific proposal using the `gov.QueryClientImpl` from `cosmjs-types`. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as gov from "cosmjs-types/cosmos/gov/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querygov = new gov.QueryClientImpl(rpcClient) let Votes = await querygov.Votes({ "proposalId": "0" }) console.log(Votes) ``` -------------------------------- ### Connect to RPC and Query Bank Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/bank/QuerySpendableBalanceByDenomRequest.md Establishes a connection to a Tendermint RPC endpoint, creates a QueryClient and ProtobufRPCClient, and initializes a QueryClientImpl for the bank module. This is a prerequisite for querying bank-related information. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as bank from "cosmjs-types/cosmos/bank/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querybank = new bank.QueryClientImpl(rpcClient) ``` -------------------------------- ### Connect to Tendermint RPC and Initialize Gov Query Client Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query-o/gov.md Establishes a connection to a Tendermint RPC endpoint and initializes a query client for the Cosmos SDK Governance module. It imports necessary modules from CosmJS and cosmjs-types. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as gov from "cosmjs-types/cosmos/gov/v1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const queryGov = new gov.QueryClientImpl(rpcClient) ``` -------------------------------- ### Connect to RPC and Get Block Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/README.md Establishes a connection to a Cosmos RPC endpoint, retrieves the latest block information, and then disconnects. It includes basic error handling. ```javascript import { StargateClient } from "@cosmjs/stargate" try { const client = await StargateClient.connect('https://rpc.cosmos.directory/cosmoshub') const getBlock = await client.getBlock() console.log(getBlock.header) client.disconnect() } catch (e) { console.log("Error! Try again") } ``` -------------------------------- ### Connect to RPC and Initialize Authz Query Client Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query-o/authz.md Establishes a connection to a Tendermint RPC endpoint and initializes the Authz query client. It imports necessary modules from @cosmjs/tendermint-rpc, @cosmjs/stargate, and cosmjs-types. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as authz from "cosmjs-types/cosmos/authz/v1beta1/query"; const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const queryAuthz = new authz.QueryClientImpl(rpcClient) ``` -------------------------------- ### Connect to RPC and Query Proposal Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/gov/QueryProposalRequest.md Establishes a connection to a Tendermint RPC endpoint, creates a query client, and demonstrates how to query proposal details using the cosmjs-stargate library. It utilizes the cosmos/gov/v1beta1 query types. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as gov from "cosmjs-types/cosmos/gov/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querygov = new gov.QueryClientImpl(rpcClient) let Proposal = await querygov.Proposal({ "proposalId": "0" }) console.log(Proposal) ``` -------------------------------- ### Connect to RPC and Query Params Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/cosmwasm/query/QueryParamsRequest.md Establishes a connection to a Tendermint RPC endpoint, creates a QueryClient and ProtobufRpcClient, and then initializes a CosmWasm QueryClientImpl to query parameters. It requires @cosmjs/tendermint-rpc, @cosmjs/stargate, and cosmjs-types. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as cosmwasm from "cosmjs-types/cosmwasm/wasm/v1/query.js" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querywasm = new cosmwasm.QueryClientImpl(rpcClient) let Params = await querywasm.Params({}) console.log(Params) ``` -------------------------------- ### Connect to RPC and Query SigningInfo Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/slashing/QuerySigningInfoRequest.md Establishes a connection to a Tendermint RPC endpoint and retrieves SigningInfo for a given consensus address. It utilizes libraries from `@cosmjs/tendermint-rpc` and `@cosmjs/stargate`, along with `cosmjs-types` for protobuf definitions. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as slashing from "cosmjs-types/cosmos/slashing/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const queryslashing = new slashing.QueryClientImpl(rpcClient) let SigningInfo = await queryslashing.SigningInfo({ "consAddress": "" }) console.log(SigningInfo) ``` -------------------------------- ### Connect to Tendermint RPC and Query Authz Grants Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/authz/QueryGranterGrantsRequest.md Establishes a connection to a Tendermint RPC endpoint using Tendermint37Client and creates a QueryClient. It then initializes an authz QueryClientImpl to interact with authorization-related queries. This setup is necessary for executing subsequent authorization grant queries. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as authz from "cosmjs-types/cosmos/authz/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const queryauthz = new authz.QueryClientImpl(rpcClient) ``` ```js let GranterGrants = await queryauthz.GranterGrants({ "granter": "" }) console.log(GranterGrants) ``` -------------------------------- ### CreateGroupWithPolicy Example Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/broadcast/group/MsgCreateGroupWithPolicy.md This snippet shows how to find the message type for creating a group with a policy and construct the final message object using @cosmjs/stargate and cosmjs-types. It includes placeholders for admin, members, and metadata, and comments out a broadcast example. ```js import { defaultRegistryTypes } from "@cosmjs/stargate"; const foundMsgType = defaultRegistryTypes.find( (element) => element[0] === "/cosmos.group.v1.MsgCreateGroupWithPolicy" ) const finalMsg = { typeUrl: foundMsgType[0], value: foundMsgType[1].fromPartial({ "admin": "", "members": [], "groupMetadata": "", "groupPolicyMetadata": "", "groupPolicyAsAdmin": false }), } // const result = await signer.client.signAndBroadcast('address', [finalMsg], "auto", "") ``` -------------------------------- ### Query Group Information Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/group/QueryGroupInfoRequest.md Retrieves information about a specific group by its ID using the initialized group query client. This example demonstrates how to call the GroupInfo method and log the result. ```js let GroupInfo = await querygroup.GroupInfo({ "groupId": "0" }) console.log(GroupInfo) ``` -------------------------------- ### Connect to RPC and Query Governance Params Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/gov/QueryParamsRequest.md Establishes a connection to a Tendermint RPC endpoint, creates a QueryClient and Protobuf RPC client, and then instantiates a governance query client to fetch parameters. It requires `@cosmjs/tendermint-rpc`, `@cosmjs/stargate`, and `cosmjs-types`. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as gov from "cosmjs-types/cosmos/gov/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querygov = new gov.QueryClientImpl(rpcClient) let Params = await querygov.Params({ "paramsType": "" }) console.log(Params) ``` -------------------------------- ### Query Governance Deposits Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/gov/QueryDepositsRequest.md Retrieves the deposits for a specific proposal ID from the governance module. This example demonstrates how to use the initialized governance query client to fetch deposit information. ```js let Deposits = await querygov.Deposits({ "proposalId": "0" }) console.log(Deposits) ``` -------------------------------- ### Connect to RPC and Query Contract Info Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/cosmwasm/query/QueryContractInfoRequest.md Demonstrates how to establish a connection to a Tendermint RPC endpoint using Tendermint37Client, create a QueryClient and ProtobufRpcClient, and then use the QueryClientImpl to fetch contract information. This requires the @cosmjs/stargate and cosmjs-types packages. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as cosmwasm from "cosmjs-types/cosmwasm/wasm/v1/query.js" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querywasm = new cosmwasm.QueryClientImpl(rpcClient) let ContractInfo = await querywasm.ContractInfo({ "address": "" }) console.log(ContractInfo) ``` -------------------------------- ### Connect to RPC and Initialize Bank Query Client Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query-o/bank.md Establishes a connection to a Tendermint RPC endpoint and initializes a query client for the Cosmos Bank module. This is a prerequisite for all subsequent bank queries. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as bank from "cosmjs-types/cosmos/bank/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const queryBank = new bank.QueryClientImpl(rpcClient) ``` -------------------------------- ### Retrieve Total Supply Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/bank/QueryTotalSupplyRequest.md Fetches the total supply of tokens from the bank module using the initialized query client. This example demonstrates how to call the `TotalSupply` method and log the result. ```js let TotalSupply = await querybank.TotalSupply({}) console.log(TotalSupply) ``` -------------------------------- ### Connect to RPC and Query DenomOwners Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/bank/QueryDenomOwnersRequest.md Establishes a connection to a Tendermint RPC endpoint using Tendermint37Client, creates a QueryClient and ProtobufRpcClient, and then instantiates a bank query client to call the DenomOwners method. The example demonstrates how to fetch denom owner information. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as bank from "cosmjs-types/cosmos/bank/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querybank = new bank.QueryClientImpl(rpcClient) let DenomOwners = await querybank.DenomOwners({ "denom": "" }) console.log(DenomOwners) ``` -------------------------------- ### Fetch Delegator Unbonding Delegations Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/staking/QueryDelegatorUnbondingDelegationsRequest.md Retrieves the unbonding delegations for a given delegator address from the Cosmos SDK staking module. This example demonstrates calling the DelegatorUnbondingDelegations method on the staking query client. ```js let DelegatorUnbondingDelegations = await querystaking.DelegatorUnbondingDelegations({ "delegatorAddr": "" }) console.log(DelegatorUnbondingDelegations) ``` -------------------------------- ### Connect to RPC and Initialize Group Query Client Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/group/QueryGroupInfoRequest.md Establishes a connection to a Tendermint RPC endpoint and initializes a query client for Cosmos group module interactions. It uses Tendermint37Client for the RPC connection and creates a Protobuf RPC client for querying. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as group from "cosmjs-types/cosmos/group/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querygroup = new group.QueryClientImpl(rpcClient) ``` -------------------------------- ### WithdrawValidatorCommission JavaScript Example Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/broadcast/distribution/MsgWithdrawValidatorCommission.md Demonstrates how to find and construct the MsgWithdrawValidatorCommission message using @cosmjs/stargate. It requires the @cosmjs/stargate and cosmjs-types libraries. The input is a validator address, and the output is a message object ready for signing and broadcasting. ```js import { defaultRegistryTypes } from "@cosmjs/stargate"; const foundMsgType = defaultRegistryTypes.find( (element) => element[0] === "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission" ) const finalMsg = { typeUrl: foundMsgType[0], value: foundMsgType[1].fromPartial({ "validatorAddress": "" }), } // const result = await signer.client.signAndBroadcast('address', [finalMsg], "auto", "") ``` -------------------------------- ### Vote() Functionality with Stargate Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/broadcast/group/MsgVote.md This snippet demonstrates how to use the Vote() function from the @cosmjs/stargate library to construct a message for voting on a proposal. It utilizes cosmjs-types to define the message structure and includes an example of finding the correct message type within the default registry. ```js import { defaultRegistryTypes } from "@cosmjs/stargate"; const foundMsgType = defaultRegistryTypes.find( (element) => element[0] === "/cosmos.group.v1.MsgVote" ) const finalMsg = { typeUrl: foundMsgType[0], value: foundMsgType[1].fromPartial({ "proposalId": "0", "voter": "", "option": 0, "metadata": "", "exec": 0 }), } // const result = await signer.client.signAndBroadcast('address', [finalMsg], "auto", "") ``` -------------------------------- ### Connect to Tendermint RPC and Query Bank Module Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/bank/QueryTotalSupplyRequest.md Establishes a connection to a Tendermint RPC endpoint and initializes clients for querying the Cosmos Bank module. It utilizes `@cosmjs/tendermint-rpc` for the RPC connection and `@cosmjs/stargate` for client creation, along with `cosmjs-types` for bank module definitions. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as bank from "cosmjs-types/cosmos/bank/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querybank = new bank.QueryClientImpl(rpcClient) ``` -------------------------------- ### VoteWeighted() Usage with Stargate Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/broadcast/gov/MsgVoteWeighted.md This snippet shows how to import necessary modules from @cosmjs/stargate, find the message type for '/cosmos.gov.v1.MsgVoteWeighted', and construct the final message object with default values for proposalId, voter, options, and metadata. It also includes a commented-out example of how to sign and broadcast the transaction. ```js import { defaultRegistryTypes } from "@cosmjs/stargate"; const foundMsgType = defaultRegistryTypes.find( (element) => element[0] === "/cosmos.gov.v1.MsgVoteWeighted" ) const finalMsg = { typeUrl: foundMsgType[0], value: foundMsgType[1].fromPartial({ "proposalId": "0", "voter": "", "options": [], "metadata": "" }), } // const result = await signer.client.signAndBroadcast('address', [finalMsg], "auto", "") ``` -------------------------------- ### Connect to RPC and Query Group Policies Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/group/QueryGroupPoliciesByAdminRequest.md Demonstrates how to establish a connection to a Tendermint RPC endpoint using Tendermint37Client, create a QueryClient and ProtobufRpcClient, and then use the QueryClientImpl for the group module to fetch group policies by a specified administrator. This involves setting up the necessary clients and making a call to the GroupPoliciesByAdmin method. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as group from "cosmjs-types/cosmos/group/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querygroup = new group.QueryClientImpl(rpcClient) let GroupPoliciesByAdmin = await querygroup.GroupPoliciesByAdmin({ "admin": "" }) console.log(GroupPoliciesByAdmin) ``` -------------------------------- ### Auto Animate Example Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/slides.md Demonstrates enabling auto-animation between slides by adding the 'data-auto-animate' attribute. ```html ## Transition ### Auto animate `data-auto-animate` can be added on nearby slides to make an animation on unchanged elements. ``` -------------------------------- ### Connect to RPC and Query Grants Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/authz/QueryGrantsRequest.md Establishes a connection to a Tendermint RPC endpoint using `@cosmjs/tendermint-rpc` and `@cosmjs/stargate`. It then initializes a query client and an `authz.QueryClientImpl` to query grants. The `Grants` query requires the `granter`, `grantee`, and `msgTypeUrl` as parameters. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as authz from "cosmjs-types/cosmos/authz/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const queryauthz = new authz.QueryClientImpl(rpcClient) let Grants = await queryauthz.Grants({ "granter": "", "grantee": "", "msgTypeUrl": "" }) console.log(Grants) ``` -------------------------------- ### Query a Specific Proposal Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query-o/gov.md Fetches details of a specific governance proposal by its ID. ```js let Proposal = await queryGov.Proposal({ proposalId: 420 }) console.log(Proposal) ``` -------------------------------- ### Connect to RPC and Initialize Feegrant Query Client Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query-o/feegrant.md Establishes a connection to a Tendermint RPC endpoint and initializes the feegrant query client. This involves creating Tendermint, Query, and Protobuf RPC clients, and then instantiating the feegrant QueryClientImpl. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as feegrant from "cosmjs-types/cosmos/feegrant/v1beta1/query"; const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const queryFeegrant = new feegrant.QueryClientImpl(rpcClient) ``` -------------------------------- ### Connect to RPC and Query Signing Information Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/slashing/QuerySigningInfosRequest.md Establishes a connection to a Tendermint RPC endpoint, creates a query client, and demonstrates how to query signing information using the slashing module. Requires @cosmjs/tendermint-rpc, @cosmjs/stargate, and cosmjs-types. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as slashing from "cosmjs-types/cosmos/slashing/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const queryslashing = new slashing.QueryClientImpl(rpcClient) let SigningInfos = await queryslashing.SigningInfos({}) console.log(SigningInfos) ``` -------------------------------- ### Connect to Tendermint RPC and Query Allowances Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/feegrant/QueryAllowancesRequest.md Demonstrates how to establish a connection to a Tendermint RPC endpoint using Tendermint37Client, create a QueryClient and ProtobufRpcClient, and then use the feegrant QueryClientImpl to fetch allowances for a given grantee. It requires the @cosmjs/stargate and cosmjs-types packages. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as feegrant from "cosmjs-types/cosmos/feegrant/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const queryfeegrant = new feegrant.QueryClientImpl(rpcClient) let Allowances = await queryfeegrant.Allowances({ "grantee": "" }) console.log(Allowances) ``` -------------------------------- ### Query All Votes for a Proposal Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query-o/gov.md Retrieves all votes cast on a specific governance proposal. Supports pagination. ```js let Votes = await queryGov.Votes({ proposalId: 420, pagination: '' }) console.log(Votes) ``` -------------------------------- ### Query a Specific Vote Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query-o/gov.md Fetches details of a specific vote cast on a proposal by a particular voter. ```js let Vote = await queryGov.Vote({ proposalId: 420, voter: '' }) console.log(Vote) ``` -------------------------------- ### Connect to RPC and Query Staking Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query-o/staking.md Establishes a connection to a Tendermint RPC endpoint and initializes a query client for the staking module. It requires the RPC URL as input. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as staking from "cosmjs-types/cosmos/staking/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const queryStaking = new staking.QueryClientImpl(rpcClient) ``` -------------------------------- ### Query All Proposals Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query-o/gov.md Retrieves a list of all governance proposals. Supports pagination for large result sets. ```js let Proposals = await queryGov.Proposals({}) console.log(Proposals) ``` -------------------------------- ### Connect to RPC and Query Proposals Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/gov/QueryProposalsRequest.md This snippet shows how to establish a connection to a Tendermint RPC endpoint using `Tendermint37Client` and then query proposals using the `QueryClientImpl` from the Cosmos Gov module. It requires `@cosmjs/stargate` and `cosmjs-types`. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as gov from "cosmjs-types/cosmos/gov/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querygov = new gov.QueryClientImpl(rpcClient) let Proposals = await querygov.Proposals({ "proposalStatus": 0, "voter": "", "depositor": "" }) console.log(Proposals) ``` -------------------------------- ### Get Block Information Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/stargate/README.md Fetches the latest block information from the connected Cosmos Hub. It then logs the header of the block to the console. ```javascript const getBlock = await client.getBlock() console.log(getBlock.header) ``` -------------------------------- ### Connect to RPC and Query Slashing Parameters Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/slashing/QueryParamsRequest.md Establishes a connection to a Tendermint RPC endpoint and demonstrates how to query slashing parameters using CosmJS. It utilizes `@cosmjs/stargate` and `cosmjs-types` for interacting with the Cosmos SDK. The code initializes clients for Tendermint RPC, Stargate query, and protobuf RPC, then instantiates a query client for slashing parameters. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as slashing from "cosmjs-types/cosmos/slashing/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const queryslashing = new slashing.QueryClientImpl(rpcClient) let Params = await queryslashing.Params({}) console.log(Params) ``` -------------------------------- ### Get Specific Balance Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/stargate/README.md Retrieves the balance of a specific denomination for a given account address. The result includes the amount and the denomination. ```javascript const getBalance = await client.getBalance('cosmos13jawsn574rf3f0u5rhu7e8n6sayx5gkwjvqrkr', 'uatom') console.log(getBalance) ``` -------------------------------- ### Connect to RPC and Initialize Clients Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/bank/QuerySendEnabledRequest.md Establishes a connection to a Tendermint RPC endpoint and initializes necessary clients for querying blockchain data using CosmJS. It sets up Tendermint, Query, and Protobuf RPC clients, along with the Bank module's QueryClientImpl. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as bank from "cosmjs-types/cosmos/bank/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querybank = new bank.QueryClientImpl(rpcClient) ``` -------------------------------- ### Get Staked Balance Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/stargate/README.md Retrieves the total staked balance for a given account address. This includes tokens that have been delegated to validators. ```javascript const getBalanceStaked = await client.getBalanceStaked('cosmos13jawsn574rf3f0u5rhu7e8n6sayx5gkwjvqrkr') console.log(getBalanceStaked) ``` -------------------------------- ### Get All Balances Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/stargate/README.md Fetches all token balances for a specified account address. This returns an array of objects, each representing a balance with its denomination and amount. ```javascript const getAllBalances = await client.getAllBalances('cosmos13jawsn574rf3f0u5rhu7e8n6sayx5gkwjvqrkr') console.log(getAllBalances) ``` -------------------------------- ### Connect to Tendermint RPC and Query Bank Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/bank/QueryAllBalancesRequest.md Establishes a connection to a Tendermint RPC endpoint using `@cosmjs/tendermint-rpc` and `@cosmjs/stargate`. It then initializes a query client and a bank query client to interact with the bank module. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as bank from "cosmjs-types/cosmos/bank/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querybank = new bank.QueryClientImpl(rpcClient) ``` -------------------------------- ### Fragment Animation Example Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/slides.md Demonstrates sequential fragment animations (fade-in, highlight-red, fade-out) applied to nested HTML elements. ```html Fade in > Turn red > Fade out ``` -------------------------------- ### Query Governance Parameters Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query-o/gov.md Fetches governance parameters, specifying the type of parameters to query (e.g., 'voting', 'tallying', 'deposit'). ```js // params_type defines which parameters to query for, can be one of "voting", "tallying" or "deposit". let Params = await queryGov.Params({ paramsType: 'voting' }) console.log(Params) ``` -------------------------------- ### Connect to RPC and Query Balance Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/bank/QueryBalanceRequest.md This snippet shows how to establish a connection to a Tendermint RPC endpoint, create a query client, and then use the bank module's QueryClientImpl to fetch an account's balance. It requires the @cosmjs/tendermint-rpc and @cosmjs/stargate packages, along with cosmjs-types for protobuf definitions. ```js import { Tendermint37Client } from "@cosmjs/tendermint-rpc" import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate" import * as bank from "cosmjs-types/cosmos/bank/v1beta1/query" const client = await Tendermint37Client.connect('{rpc_url}') const queryClient = new QueryClient(client) const rpcClient = createProtobufRpcClient(queryClient) const querybank = new bank.QueryClientImpl(rpcClient) let Balance = await querybank.Balance({ "address": "", "denom": "" }) console.log(Balance) ``` -------------------------------- ### Fetch All Balances Source: https://github.com/atmoner/cosmjs-examples/blob/main/src/query/bank/QueryAllBalancesRequest.md Retrieves all balances for a specified address by calling the `AllBalances` method on the bank query client. The result is then logged to the console. ```js let AllBalances = await querybank.AllBalances({ "address": "" }) console.log(AllBalances) ```