-
Notifications
You must be signed in to change notification settings - Fork 196
02QueryingChainAuction
Ivan Angelkoski edited this page Jun 12, 2023
·
4 revisions
Example code snippets to query the auction module on the chain.
- Fetch module params such as the auction period
import { ChainGrpcBankApi } from "@injectivelabs/sdk-ts";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";
const endpoints = getNetworkEndpoints(Network.TestnetK8s);
const chainGrpcAuctionApi = new ChainGrpcAuctionApi(endpoints.grpc);
const moduleParams = await chainGrpcAuctionApi.fetchModuleParams();
console.log(moduleParams);
- Get the state of the current auction, such as the latest round
import { ChainGrpcBankApi } from "@injectivelabs/sdk-ts";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";
const endpoints = getNetworkEndpoints(Network.TestnetK8s);
const chainGrpcAuctionApi = new ChainGrpcAuctionApi(endpoints.grpc);
const latestAuctionModuleState = await auctionApi.fetchModuleState();
console.log(latestAuctionModuleState);
- Fetch the current auction basket and get info such as the highest bidder and amount
import { ChainGrpcBankApi } from "@injectivelabs/sdk-ts";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";
const endpoints = getNetworkEndpoints(Network.TestnetK8s);
const chainGrpcAuctionApi = new ChainGrpcAuctionApi(endpoints.grpc);
const currentBasket = await chainGrpcAuctionApi.fetchCurrentBasket();
console.log(currentBasket);
Powering the future of decentralized finance.