Catalog npm
Back to packageRELEASE DETAILS

0.15.0

npm

@0xslots/sdk

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

Published13 Apr 2026
Direct dependencies16
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 16

Native requirements
16 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
@0xslots/contracts
Environment
{
  "local_name": "@0xslots/contracts",
  "alias": false,
  "peer_metadata": null
}
0.11.0runtime
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
@types/react
Environment
{
  "local_name": "@types/react",
  "alias": false,
  "peer_metadata": null
}
^19development
@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
viem
Environment
{
  "local_name": "viem",
  "alias": false,
  "peer_metadata": null
}
>=2peer
react
Environment
{
  "local_name": "react",
  "alias": false,
  "peer_metadata": {
    "optional": true
  }
}
>=18peer
wagmi
Environment
{
  "local_name": "wagmi",
  "alias": false,
  "peer_metadata": {
    "optional": true
  }
}
>=2peer
@tanstack/react-query
Environment
{
  "local_name": "@tanstack/react-query",
  "alias": false,
  "peer_metadata": {
    "optional": true
  }
}
>=5peer

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "b4af6510018d42f3e90977985800787bee4f9072",
  "tarball": "https://registry.npmjs.org/@0xslots/sdk/-/sdk-0.15.0.tgz",
  "fileCount": 11,
  "integrity": "sha512-C1g5MjAvK+tMzxuVqb4/ZP2pcNCQpq/DNWdcBLTqxoOLMvIMKu29tpOhSswxwuylvpBvM0CeHJO1pgwU99NqLQ==",
  "signatures": [
    {
      "sig": "MEYCIQDE7vvK8JcgzjvDKJjZIiyei3YgcFB+jdbfvX+Y34GjMQIhAMHZieqDiFqPJHbbyrgtiB1HdTYJjKSIOSfHztcjialw",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 734858
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 11:30 UTC

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

Record identity

package_version:a6f9fd45c844b0b8211d7875cf30f0aeb8ded12dfd2b54915830c87abac35771

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 →