React Hooks
Wagmi-wired hooks from @0xslots/sdk/react. Requires wagmi, viem, and @tanstack/react-query as peer dependencies.
useSlotsClient
Creates a memoized SlotsClient from wagmi's public and wallet clients.
import { useSlotsClient } from "@0xslots/sdk/react";
const client = useSlotsClient(); // connected chain
const client = useSlotsClient(SlotsChain.BASE); // override chain
const client = useSlotsClient(SlotsChain.BASE, "api-key"); // with subgraph keyuseSlotAction
Unified write executor with transaction lifecycle tracking.
import { useSlotAction } from "@0xslots/sdk/react";
const {
buy, selfAssess, topUp, withdraw, release, collect, liquidate,
createSlot, proposeTaxUpdate, proposeModuleUpdate, updateMetadata,
exec, // generic executor
busy, // isPending || isConfirming
isPending, // wallet interaction in progress
isConfirming, // waiting for on-chain confirmation
isSuccess,
activeAction, // label of current action
} = useSlotAction({
onSuccess: (label, hash) => console.log(`${label}: ${hash}`),
onError: (label, error) => console.error(`${label}: ${error}`),
});useSlotOnChain
Fetches a single slot's state from on-chain via RPC. Auto-invalidates on new blocks.
import { useSlotOnChain } from "@0xslots/sdk/react";
const { data: slot, isLoading, refetch } = useSlotOnChain(address, 8453);
// slot: { occupant, price, deposit, taxPercentage, insolvent, currencySymbol, ... }useSlotsOnChain
Fetches multiple slots via multicall. Deduplicates currency metadata requests.
import { useSlotsOnChain } from "@0xslots/sdk/react";
const { data: slots, isLoading } = useSlotsOnChain(addresses, 8453);