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 chainThe hook takes one parameter. The old second argument was a subgraph API
key; the indexer serves GraphQL unauthenticated, and passing the key through
NEXT_PUBLIC_* published a credential to every visitor in exchange for nothing.
It resolves the factory address from the chain and throws if there is none.
For a client against a non-default endpoint — a local indexer, or your own
deployment behind auth — construct SlotsClient directly and memoize it
yourself; the hook always uses DEFAULT_API_URL.
useSlotAction
Unified write executor with transaction lifecycle tracking.
import { useSlotAction } from "@0xslots/sdk/react";
const {
buy, selfAssess, topUp, withdraw, release, collect, liquidate,
createSlot, createSlots, createSlotWithTenure, createSlotWithPriceFloor,
proposeTaxUpdate, proposeUtilityUpdate, proposePolicyUpdate,
cancelPendingUpdate, cancelPendingUpdates, setLiquidationBounty,
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}`),
});proposeModuleUpdate is still returned, as a deprecated alias for
proposeUtilityUpdate.
cancelPendingUpdate(slot, kind) retracts one of a slot's three governable
dimensions; cancelPendingUpdates(slot) retracts all of them.
import { UpdateKind } from "@0xslots/sdk"; // Tax = 0, Utility = 1, Policy = 2
await cancelPendingUpdate(slot, UpdateKind.Tax);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);