Skip to main content

Interacting with RPC endpoints

As shown on the RPC specifications, there are different endpoints to communicate with the Terp Core chain. Unlike the LCD rest api, the RPC endpoints provide genereic endpoints to communicate with the various modules available. For example the ABCI Query allows you the query different data from Terp.

For more information please read generating, [signing and boradcasting transactions.] https://docs.cosmos.network/v0.46/run-node/txs.html on the cosmos-sdk docs.

Querying the ABCI Query with Javascript via Telescope

If you are looking to query, sign and broadcast transactions using Javascript. Telescope and OsmoJS make this very easy. The following is a very simple example of you could acomplish this using Telescope.

Setting up Telescope

# Install dependencies
yarn install
# Install Telescope
npm install -g @osmonauts/telescope
# Select the chains you would like to interact with
telescope install
# Generate types
yarn codegen

Simple query example

Edit src/index.ts


import { terpjs } from "./codegen";
const { createRPCQueryClient } = terp.ClientFactory;


async function getBalance() {

const client = await createRPCQueryClient({ rpcEndpoint: "https://rpc-terp.zenchainlabs.io" });
// // now you can query the cosmos modules
const balance = await client.cosmos.bank.v1beta1
.allBalances({ address: 'terp1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3aq6l09' });
}

getBalance().catch(console.error);

Run the code and see the responses from the rpc endpoint.

yarn dev

For extended details and documentations, see the documentation for Telescope.