-
Notifications
You must be signed in to change notification settings - Fork 196
02QueryingCosmWasm
Ivan Angelkoski edited this page Jun 12, 2023
·
6 revisions
We can retrieve data from the smart contract using it's query function with the ChainGrpcWasmApi fetchSmartContractState
grpc function.
import { ChainGrpcWasmApi } from "@injectivelabs/sdk-ts";
const contractAddress = "inj...";
const injectiveAddress = "inj...";
// update the payload based on the contract's query function and arguments
const payload = {
address: injectiveAddress,
};
const query = Buffer.from(JSON.stringify(payload)).toString("base64");
const response = await chainGrpcWasmApi.fetchSmartContractState(
contractAddress,
query
);
const data = JSON.parse(Buffer.from(response.data).toString());
console.log(data);
Powering the future of decentralized finance.