-
Notifications
You must be signed in to change notification settings - Fork 204
06Networks
Building dApps on Injective requires being able to tap into different environments and networks where you can test your dApp with ease. As part of the injective-ts monorepo, we have the @injectivelabs/networks package which allows developers to easily access pre-defined environments to connect to different pieces of Injective.
There are two key functions exported from this package:
export function getEndpointsForNetwork(network: Network): NetworkEndpointsexport function getNetworkInfo(network: Network): ChainInfo
The first one, getEndpointsForNetwork returns a pre-defined set of endpoints that can be used by the developers - depending on their need. Here is the interface that gets returned from this function:
export type NetworkEndpoints = {
exchangeApi: string // @deprecated - the grpc-web port of the exchange API service
indexerApi: string // the grpc-web port of the indexer API service
sentryGrpcApi: string // the grpc-web port of the sentry node
sentryHttpApi: string // the REST endpoint of the sentry node
tendermintApi?: string // the REST endpoint of the Tendermint RPC
chronosApi?: string // the REST endpoint of the chronos API service
exchangeWeb3GatewayApi?: string // the grpc-web port of the web3-gateway service API
}Lets explain these endpoints, and what do they mean:
-
exchangeApi/indexerApiis the grpc-web endpoint that we can use to connect to theexchange/indexerservice which listens for events from the chain, processes the events and stores the data into a mongoDB so its easier and much more performant to serve that data than querying it straight from the chain itself, -
sentryGrpcApiis the grpc-web endpoint that we can use to connect to a sentry node. A Sentry node is basically a read (and light) only version of the chain that we can use to query data directly from the chain. -
sentryHttpApiis the REST endpoint that we can use to connect to a sentry node. -
tendermintApiis the REST endpoint that we can use to connect to the Tendermint RPC, -
chronosApiis the REST endpoint that we can use to connect to the Chronos API which is part of theexchange/indexerservice which is used for rendering the TradingView chart and getting OHLC data for the markets, -
exchangeWeb3GatewayApiis the grpc-web endpoint that we can use to connect to the web3-gateway which is part of theexchange/indexerservice which is used for preparing and broadcasting Cosmos transactions using Ethereum native wallets + supports for fee delegation
The getNetworkInfo exports these endpoints plus the chainId and the default fee for the Network we want.
Powering the future of decentralized finance.