-
Notifications
You must be signed in to change notification settings - Fork 196
02QueryingChain
Bojan Angjelkoski edited this page Nov 6, 2022
·
8 revisions
Example code snippets to query the bank module on the chain using the gRPC protocol.
- Fetching address's balances
import { ChainGrpcBankApi } from '@injectivelabs/sdk-ts'
import { getEndpointsForNetwork, Network } from "@injectivelabs/networks";
const endpoints = getEndpointsForNetwork(Network.TestnetK8s);
const injectiveAddress = 'inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku'
const chainGrpcBankApi = new ChainGrpcBankApi(endpoints.sentryGrpcApi)
const balances = await chainGrpcBankApi.fetchBalances(injectiveAddress)
console.log(balances)
Example code snippets to query the bank module on the chain using the REST protocol.
- Fetching address's balances
import { ChainRestBankApi } from '@injectivelabs/sdk-ts'
import { getEndpointsForNetwork, Network } from "@injectivelabs/networks";
const endpoints = getEndpointsForNetwork(Network.TestnetK8s);
const injectiveAddress = 'inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku'
const chainRestBankApi = new ChainRestBankApi(endpoints.sentryHttpApi)
const balances = await chainGrpcBankApi.fetchBalances(injectiveAddress)
console.log(balances)
Powering the future of decentralized finance.