Catalog npm
PACKAGE EXPLORERView in registry

@0xslots/sdk

npm

Type-safe SDK for the 0xSlots protocol — reads (subgraph) + writes (viem)

Versions collected57
Direct dependencies17From release 1.0.1
Last observed21 Oct, 11:30 UTC

README

Current package documentation

@0xslots/sdk

Type-safe SDK for the 0xSlots protocol — contract reads and writes over viem, with ERC-20 approval handled for you. Full reference: docs.0xslots.org.

Install

pnpm add @0xslots/sdk @0xslots/contracts viem

Usage

import { SlotsClient } from "@0xslots/sdk";
import { slotFactoryAddress } from "@0xslots/contracts";

const client = new SlotsClient({
  publicClient,                                  // viem PublicClient
  walletClient,                                  // viem WalletClient, for writes
  factoryAddress: slotFactoryAddress[chainId],   // only createSlot / collectAll need it
});

const state = await client.slotState(slot);      // one SlotLens.getSlotInfo call

// `account` is who becomes occupant — it need not be the signer.
await client.buy({
  slot,
  account,
  selfAssessedPrice: 5_000_000n,
  depositAmount: 1_000_000n,
});

await client.topUp(slot, 500_000n);
await client.release(slot);
await client.collect(slot);

SlotsClient reads the chain, not the indexer. The indexer endpoints are exported as DEFAULT_API_URL, LOCAL_API_URL, API_URLS and apiUrlFor(env) for querying it directly — see Indexer.

Surface

AreaMethods
ReadsslotState, slotStates, quoteBuy, minDepositForBuy, minDepositToHold, pending, hasRipeTerms, terms, module, scopes, fee, moduleUpdate, debtOf, claimableOf, isOperator, and getters for the common fields
CreatecreateSlot, simulateCreateSlot
Occupancybuy, simulateBuy, liquidateAndBuy, release, liquidate
HoldingselfAssess, topUp, withdraw, manageTerms, setOperator
Money outcollect, collectAll, simulateCollectAll, collectFrom, claim
ManagerproposeTerms, cancelTerms, acceptFee, acceptScopes, setManager
ModulesvalidateSettings, readScopes, readFee, moduleMetadata, moduleSettings
OfferBookofferBoard, offerAt, isOfferFundable, offerCost, postOffer, cancelOffer, approveOfferBook, authorizeOfferBook, acceptOffer

buy sends the quote it just read as maxPayment, so it pays what it was quoted or reverts; pass maxPayment: 0n to disable the ceiling on purpose. Call simulateBuy first to surface a module's refusal with its own error.

Terms are proposed by presence, and land at the next buy after a one-day delay:

import { NO_MODULE, TERMS } from "@0xslots/sdk";

await client.proposeTerms(slot, { taxRateBps: 200 });
await client.proposeTerms(slot, { moduleTerms: { module, settings } });
await client.proposeTerms(slot, { moduleTerms: NO_MODULE }); // remove the module
await client.cancelTerms(slot, TERMS.MODULE);

CollectionsClient (slot-bound NFT collections) and CollectivesClient (SlotCollective governance, roles in COLLECTIVE_ROLES) ship beside it.

React

import { useSlotAction, useSlotsClient } from "@0xslots/sdk/react";

Requires wagmi, viem and @tanstack/react-query as peer dependencies. useSlotsClient({ factoryAddress?, offerBookAddress?, chainId? }) memoizes a client from wagmi's clients; useSlotAction wraps every write with shared pending and receipt state. useCollectivesClient does the same for collectives.

License

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 57

Collected releases
VersionPublishedDirect dependenciesOpen version
1.0.1Registry latest30 Sept 202617
1.0.030 Sept 202617
0.30.211 Sept 202617
0.30.19 Sept 202617
0.30.08 Sept 202617
0.29.07 Sept 202617
0.28.01 Sept 202617
0.27.015 Aug 202617
0.26.114 Aug 202617
0.26.012 Aug 202617
0.25.012 Aug 202617
0.24.012 Aug 202617
0.23.012 Aug 202617
0.22.011 Aug 202617
0.21.011 Aug 202617
0.20.110 Aug 202617
0.20.08 Aug 202617
0.19.08 Aug 202616
0.18.14 Aug 202616
0.18.03 Aug 202616

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 11:29 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:9ef2ad80c8e7502a18390b17c3fc5bd8eceaf9a374df1d2cbf0342c04554c6d9