Observed since 21 Oct, 11:29 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
@0xslots/sdk
Type-safe SDK for querying 0xSlots subgraph data
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.
pnpm add @0xslots/sdk @0xslots/contracts viem
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.
| Area | Methods |
|---|---|
| Reads | slotState, slotStates, quoteBuy, minDepositForBuy, minDepositToHold, pending, hasRipeTerms, terms, module, scopes, fee, moduleUpdate, debtOf, claimableOf, isOperator, and getters for the common fields |
| Create | createSlot, simulateCreateSlot |
| Occupancy | buy, simulateBuy, liquidateAndBuy, release, liquidate |
| Holding | selfAssess, topUp, withdraw, manageTerms, setOperator |
| Money out | collect, collectAll, simulateCollectAll, collectFrom, claim |
| Manager | proposeTerms, cancelTerms, acceptFee, acceptScopes, setManager |
| Modules | validateSettings, readScopes, readFee, moduleMetadata, moduleSettings |
| OfferBook | offerBoard, 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.
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.
MIT
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
graphqlEnvironment{
"local_name": "graphql",
"alias": false,
"peer_metadata": null
} | ^16.9.0 | runtime |
graphql-tagEnvironment{
"local_name": "graphql-tag",
"alias": false,
"peer_metadata": null
} | ^2.12.6 | runtime |
graphql-requestEnvironment{
"local_name": "graphql-request",
"alias": false,
"peer_metadata": null
} | ^7.2.2 | runtime |
tsupEnvironment{
"local_name": "tsup",
"alias": false,
"peer_metadata": null
} | ^8.0.0 | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^5.4.4 | development |
@types/nodeEnvironment{
"local_name": "@types/node",
"alias": false,
"peer_metadata": null
} | ^20.10.8 | development |
@graphql-codegen/cliEnvironment{
"local_name": "@graphql-codegen/cli",
"alias": false,
"peer_metadata": null
} | ^5.0.4 | development |
@graphql-codegen/typescriptEnvironment{
"local_name": "@graphql-codegen/typescript",
"alias": false,
"peer_metadata": null
} | ^4.1.3 | development |
@graphql-codegen/typescript-operationsEnvironment{
"local_name": "@graphql-codegen/typescript-operations",
"alias": false,
"peer_metadata": null
} | ^4.4.2 | development |
@graphql-codegen/typescript-graphql-requestEnvironment{
"local_name": "@graphql-codegen/typescript-graphql-request",
"alias": false,
"peer_metadata": null
} | ^6.3.0 | development |
Source distribution
{
"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
}Observed since 21 Oct, 11:29 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:7734c583db3db35dbfdad631e8d9167e96c8d5962d56486a0dfbe19e6d78aedb