Skip to main content

useStargateClient

Hook to retrieve a StargateClient.

Usage

Single Chain
import { useStargateClient } from "graz";

function App() {
const { data: client, isFetching, refetch, ... } = useStargateClient();

async function getAccountFromClient() {
return await client.getAccount("address")
}
}
Multi Chain
import { useStargateClient } from "graz";

function App() {
const { data: client, isFetching, refetch, ... } = useStargateClient({
chainId: ["cosmoshub-4", "sommelier-1"],
multiChain: true
});

async function getAccountFromClient() {
return await client["cosmoshub-4"].getAccount("address")
}
}

Hook Params

<TMultiChain extends boolean>{
chainId?: string | string[];
multiChain?: TMultiChain; // boolean
}

Return Value

{
data?: TMultiChain extends true ? Record<string, StargateClient> : StargateClient;
dataUpdatedAt: number;
error: TError | null;
errorUpdatedAt: number;
failureCount: number;
errorUpdateCount: number;
isError: boolean;
isFetched: boolean;
isFetchedAfterMount: boolean;
isFetching: boolean;
isLoading: boolean;
isLoadingError: boolean;
isPaused: boolean;
isPlaceholderData: boolean;
isPreviousData: boolean;
isRefetchError: boolean;
isRefetching: boolean;
isStale: boolean;
isSuccess: boolean;
refetch:(options?: RefetchOptions & RefetchQueryFilters) => Promise<QueryObserverResult<TMultiChain extends true ? Record<string, StargateClient> : StargateClient;, unknown>>;
remove: () => void;
status: 'loading' | 'error' | 'success';
fetchStatus: 'fetching' | 'paused' | 'idle';
}