Catalog npm
Back to packageRELEASE DETAILS

0.4.0

npm

@0xslots/sdk

Type-safe SDK for querying 0xSlots subgraph data

Published17 Feb 2026
Direct dependencies10
Transitive dependenciesNot calculated

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.

Declared dependencies 10

Native requirements
10 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
graphql
Environment
{
  "local_name": "graphql",
  "alias": false,
  "peer_metadata": null
}
^16.9.0runtime
graphql-tag
Environment
{
  "local_name": "graphql-tag",
  "alias": false,
  "peer_metadata": null
}
^2.12.6runtime
graphql-request
Environment
{
  "local_name": "graphql-request",
  "alias": false,
  "peer_metadata": null
}
^7.2.2runtime
tsup
Environment
{
  "local_name": "tsup",
  "alias": false,
  "peer_metadata": null
}
^8.0.0development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5.4.4development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^20.10.8development
@graphql-codegen/cli
Environment
{
  "local_name": "@graphql-codegen/cli",
  "alias": false,
  "peer_metadata": null
}
^5.0.4development
@graphql-codegen/typescript
Environment
{
  "local_name": "@graphql-codegen/typescript",
  "alias": false,
  "peer_metadata": null
}
^4.1.3development
@graphql-codegen/typescript-operations
Environment
{
  "local_name": "@graphql-codegen/typescript-operations",
  "alias": false,
  "peer_metadata": null
}
^4.4.2development
@graphql-codegen/typescript-graphql-request
Environment
{
  "local_name": "@graphql-codegen/typescript-graphql-request",
  "alias": false,
  "peer_metadata": null
}
^6.3.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "5388878512b2de96477e46094cacf03b5beb4fe8",
  "tarball": "https://registry.npmjs.org/@0xslots/sdk/-/sdk-0.4.0.tgz",
  "fileCount": 5,
  "integrity": "sha512-fc4DEFsPemew/BpjKVFaKdTLsZpozZlWjHjtTLJlbsUELUdBb9CVe338t27rtt4LnkbvXvhaPbEOBBjTzAjz+A==",
  "signatures": [
    {
      "sig": "MEYCIQDxMmpvN0ikrkRcPnhtHLXIfDZoDTzOHsVKKzfY0apEKQIhALYI6mDpABx2ul09Lv7FGy63lNDpxEQV4Twy48IRSz75",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 315053
}

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_version:7734c583db3db35dbfdad631e8d9167e96c8d5962d56486a0dfbe19e6d78aedb

Other collected versions

1.0.130 Sept1.0.030 Sept0.30.211 Sept0.30.19 Sept0.30.08 Sept0.29.07 SeptView all collected versions →