메인 콘텐츠로 건너뛰기
체인에서 Auth 모듈을 쿼리하는 예제 코드 스니펫입니다.

gRPC 사용

최대 메모 문자 수, 트랜잭션 서명 제한 등 파라미터 조회

import { ChainGrpcAuthApi } from "@injectivelabs/sdk-ts/client/chain";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";

const endpoints = getNetworkEndpoints(Network.Testnet);
const chainGrpcAuthApi = new ChainGrpcAuthApi(endpoints.grpc);

const moduleParams = await chainGrpcAuthApi.fetchModuleParams();

console.log(moduleParams);

Injective 주소와 관련된 계정 상세 정보 조회 (주소, 시퀀스, pub_key 등)

import { ChainGrpcAuthApi } from "@injectivelabs/sdk-ts/client/chain";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";

const endpoints = getNetworkEndpoints(Network.Testnet);
const chainGrpcAuthApi = new ChainGrpcAuthApi(endpoints.grpc);
const injectiveAddress = "inj...";

const accountDetailsResponse = await chainGrpcAuthApi.fetchAccount(
  injectiveAddress
);

console.log(accountDetailsResponse);

체인의 계정 목록 조회

import { PaginationOption } from '@injectivelabs/sdk-ts/types'
import { ChainGrpcAuthApi } from '@injectivelabs/sdk-ts/client/chain'
import { getNetworkEndpoints, Network } from '@injectivelabs/networks'

const endpoints = getNetworkEndpoints(Network.Testnet)
const chainGrpcAuthApi = new ChainGrpcAuthApi(endpoints.grpc)
const injectiveAddress = 'inj...'
const pagination = {...} as PaginationOption

const accounts = await chainGrpcAuthApi.fetchAccounts(/* optional pagination params*/)

console.log(accounts)

HTTP REST 사용

Injective 주소와 관련된 계정 상세 정보 조회 (주소, 시퀀스, pub_key 등)

import { ChainRestAuthApi } from "@injectivelabs/sdk-ts/client/chain";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";

const endpoints = getNetworkEndpoints(Network.Testnet);
const chainRestAuthApi = new ChainRestAuthApi(endpoints.rest);
const injectiveAddress = "inj...";

const accountDetailsResponse = await chainRestAuthApi.fetchAccount(
  injectiveAddress
);

console.log(accountDetailsResponse);

Injective 주소에서 Cosmos 주소 조회

import { ChainRestAuthApi } from "@injectivelabs/sdk-ts/client/chain";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";

const endpoints = getNetworkEndpoints(Network.Testnet);
const chainRestAuthApi = new ChainRestAuthApi(endpoints.rest);
const injectiveAddress = "inj...";

const cosmosAddress = await chainRestAuthApi.fetchCosmosAccount(
  injectiveAddress
);

console.log(cosmosAddress);