SlotsClient
The main entry point for interacting with 0xSlots. Source
Constructor
import { SlotsClient, SlotsChain } from "@0xslots/sdk";
const client = new SlotsClient({
chainId: SlotsChain.BASE, // BASE (8453) or BASE_SEPOLIA (84532)
publicClient, // viem PublicClient
walletClient, // viem WalletClient (for writes)
subgraphApiKey, // optional — Bearer token
});Subgraph Queries
const { slots } = await client.getSlots({ first: 10, skip: 0 });
const { slot } = await client.getSlot({ id: "0x..." });
const { slots } = await client.getSlotsByRecipient({ recipient: "0x..." });
const { slots } = await client.getSlotsByOccupant({ occupant: "0x..." });
const { factory } = await client.getFactory();
const { modules } = await client.getModules({ first: 10 });
const activity = await client.getSlotActivity({ slot: "0x..." });
const events = await client.getRecentEvents({ first: 20 });RPC Reads
const info = await client.getSlotInfo("0x...");
// Returns: recipient, currency, occupant, price, deposit, taxPercentage,
// taxOwed, secondsUntilLiquidation, insolvent, pendingTax, pendingModule, ...Write Methods
All return Promise<Hash>. ERC-20 approval is handled automatically (atomic via EIP-5792 when supported).
// Factory
await client.createSlot({ recipient, currency, config, initParams });
await client.createSlots({ ...params, count: 5n });
// Slot interactions
await client.buy({ slot, depositAmount, selfAssessedPrice });
await client.selfAssess(slot, newPrice);
await client.topUp(slot, amount);
await client.withdraw(slot, amount);
await client.release(slot);
await client.collect(slot);
await client.liquidate(slot);
// Manager
await client.proposeTaxUpdate(slot, newPct);
await client.proposeModuleUpdate(slot, newModule);
await client.cancelPendingUpdates(slot);
await client.setLiquidationBounty(slot, newBps);
// Multicall
await client.multicall(slot, [
{ functionName: "selfAssess", args: [newPrice] },
{ functionName: "topUp", args: [amount] },
]);Modules
await client.modules.metadata.getSlots({ first: 10 });
await client.modules.metadata.getURI(moduleAddress, slotAddress);
await client.modules.metadata.updateMetadata(moduleAddress, slotAddress, "ipfs://...");