SDK/Reference

Sale rooms

TESTNETPREVIEW

The sale-room surface: configuration, reads, the refusals checked before signing, the transaction builders, the seller's client (EsseySeller) and the shielded wallet (ShieldedWallet). EsseyAgent.bidSaleRoom is in EsseyAgent; how they fit together is in Sale rooms with the SDK. The shielded client underneath ShieldedWallet (buildBid, buildWithdraw, scanWallet, rebuildTree, deriveKeys, relayFresh, sendToRelayer, snarkjsProver, the statement builders) is exported as well, from shielded/*.ts. sendToRelayer, its Sent result and the RelayBody it posts have their entries in Sealed settlement v2, next to newDeposit and readerTarget.

Signatures below are copied from the source; descriptions are the source's own doc comments. Every refusal is an EsseyError thrown before anything is signed; a chain refusal is not thrown, it returns Landed with ok: false and an abort.

From sale-room.ts#

Exported by index.ts.

SaleRoomConfig#

A sale-room package and the Seal setup its room.move pins. A bid must name exactly these key servers, in this order, and this threshold (room.move is_room_ciphertext), so they are configuration: a republish swaps all four together.

TypeScript
export type SaleRoomConfig = {
  pkg: string;
  privacyPkg: string;
  passKey: string;
  /** The shared essey_access::access::Access that room::open and room::bid are gated by. */
  access: string;
  keyServers: string[];
  threshold: number;
};

TESTNET_SALE_ROOM#

The live testnet packages (publish D7E6REAm…, 2026-11-05, immutable): room.move KEY_SERVERS :35-38 in that order (Mysten's two testnet servers, then its committee server) and THRESHOLD 2 :26. membership and pool live in their own privacy package, so privacyPkg is not the same id as pkg.

TypeScript
export const TESTNET_SALE_ROOM: SaleRoomConfig = {
  pkg: "0x48db0307be9b6aadbf9f29c28561e1b450348ab2786ea4853a8d7249c22979a1",
  privacyPkg: "0xef63ef732c30b87589ed9435a8291e72fed00f7bdc72a028196c244333c2464c",
  passKey: "0xbcebf7f4430c69ee3a53cc858db659509f125d260e8e647c4865de6295a2438d",
  access: "0xe5c5cf68662a21c42bab89b1b55b623f4bf05698703d88e8479ade15352e8b94",
  keyServers: [
    "0x73d05d62c18d9374e3ea529e8e0ed6161da1a141a94d3f76ae3fe4e99356db75",
    "0xf5d14a81a982144ae441cd7d64b09027f116a468bd36e7eca494f750591623c8",
    "0xb012378c9f3799fb5b1a7083da74a4069e3c3f1c93de0b27212a5799ce1e1e98",
  ],
  threshold: 2,
};

SALE_ROOM_RULES#

room.move MAX_BIDS_CEILING :22 and MIN_FINISH_WINDOW_MS :29. P3: room.move MAX_OPEN_MS, the longest a room may take bids (close_ms - now); the issuer's pin-reset cooldown relies on it.

TypeScript
export const SALE_ROOM_RULES = {
  maxBidsCeiling: 50,
  minFinishWindowMs: 1_800_000,
  maxOpenMs: 30 * 86_400_000,
} as const;

ROOM_STATE#

TypeScript
export const ROOM_STATE = { open: 0, finished: 1, cancelled: 2, expired: 3 } as const;

SaleRoomView#

TypeScript
export type SaleRoomView = {
  id: string;
  itemType: string;
  coinType: string;
  seller: string;
  itemId: string | null;
  minPrice: bigint;
  maxPrice: bigint;
  closeMs: number;
  finishByMs: number;
  maxBids: number;
  state: number;
  shieldedOnly: boolean;
  /** One per bid: an address, or null for a shielded bidder, which has no address on chain. */
  bidders: (string | null)[];
  /** P3: one per bid, the member tag room.move dedupes on (`Bid.tag`), for address and shielded bids alike. */
  bidTags?: bigint[];
  /** P3-5 (next publish): the seller's attested member tag (null until `attest_seller`), and whether bids wait for it. */
  sellerTag?: bigint | null;
  needsSellerTag?: boolean;
  /** null: no winner yet or none; `address` null: a shielded bidder won and claims with its salt. */
  winner: { address: string | null } | null;
  price: bigint;
};

PassKeyView#

membership::PassKey as it is on chain (membership.move:48-54).

TypeScript
export type PassKeyView = { ax: bigint; ay: bigint; version: bigint; epoch: bigint };

SaleTerms#

What the room's open takes; coinType defaults to SUI and the finish window to room.move's minimum.

TypeScript
export type SaleTerms = {
  minPrice: bigint;
  maxPrice: bigint;
  closeMs: number;
  maxBids: number;
  finishWindowMs?: number;
  shieldedOnly?: boolean;
  coinType?: string;
  /** A sender-bound pass minted for the Access object; null or absent while the Access is PUBLIC. */
  gate?: Pass | null;
};

FinishShares#

TypeScript
export type FinishShares = { indices: number[]; derived: Uint8Array[] };

saleRoomOf#

proto/sale_room/deployment..json: packageId and passKey, plus keyServers and threshold unless given here.

TypeScript
export function saleRoomOf(
  raw: Record<string, unknown>,
  seal: Partial<Pick<SaleRoomConfig, "keyServers" | "threshold">> = {},
): SaleRoomConfig

bidKeyId#

The room's Seal identity, room.move key_id: the room id's bytes then "bids".

TypeScript
export const bidKeyId = (roomId: string) =>

sealServerConfigs#

TypeScript
export const sealServerConfigs = (keyServers: string[]) =>

saleSealClient#

TypeScript
export function saleSealClient(
  client: SuiGrpcClient,
  cfg: SaleRoomConfig,
  extra: Pick<SealClientOptions, "fetch" | "timeout"> = {},
)

readSaleRoom#

TypeScript
export async function readSaleRoom(
  client: SuiGrpcClient,
  cfg: SaleRoomConfig,
  roomId: string,
): Promise<SaleRoomView>

readPassKey#

The package's PassKey: refused unless it is that package's membership::PassKey, so a mixed-up config fails here.

TypeScript
export async function readPassKey(client: SuiGrpcClient, cfg: SaleRoomConfig): Promise<PassKeyView>

passFault#

What membership.move from_proof would reject for holder; null when it passes.

TypeScript
export function passFault(
  _cfg: SaleRoomConfig,
  key: PassKeyView,
  pass: ProvedPass,
  holder: string,
  nowMs: number,
): string | null

BidAsk#

tag: the member tag the bid will carry; defaults to pass.tag, the credential tag room.move dedupes on (EAlreadyBid 15).

TypeScript
export type BidAsk = { bidder: string; price: bigint; pass: ProvedPass; tag?: bigint };

bidRefusal#

Why a bid would be refused, before anything is sealed or signed, in the chain's own order (from_proof, then room::bid); null when the chain would take it. A price outside the range lands on chain and is dropped at the finish (room.move price_of), so it is refused here too.

TypeScript
export function bidRefusal(
  cfg: SaleRoomConfig,
  room: SaleRoomView,
  key: PassKeyView,
  ask: BidAsk,
  nowMs: number,
): string | null

sealedBidFault#

What room.move is_room_ciphertext would reject in sealed (room abort 7, EBadSealedBid); null when it would pass.

TypeScript
export function sealedBidFault(
  sealed: Uint8Array,
  cfg: SaleRoomConfig,
  roomId: string,
  bidder: string,
): string | null

sealBidPrice#

The price, sealed to the room's identity and bound to the bidder's address, checked as room.move will check it.

TypeScript
export async function sealBidPrice(
  seal: Pick<SealClient, "encrypt">,
  cfg: SaleRoomConfig,
  roomId: string,
  bidder: string,
  price: bigint,
): Promise<Uint8Array>

assertNotSeller#

A seller never bids in its own room. Refused here before signing; the live package refuses it too (room abort 20, ESellerBid).

TypeScript
export function assertNotSeller(room: Pick<SaleRoomView, "id" | "seller">, bidder: string): void

saleBidTx#

Membership has no abilities, so membership::from_proof and room::bid share one transaction; the deposit is max_price.

TypeScript
export function saleBidTx(
  cfg: SaleRoomConfig,
  room: SaleRoomView,
  pass: ProvedPass,
  sealed: Uint8Array,
): Transaction

openRefusal#

room.move open :138-141 (room abort 10); null when the chain would open the room.

TypeScript
export function openRefusal(terms: SaleTerms, nowMs: number): string | null

saleOpenTx#

Any key+store object the sender owns, of type item.type; the room is shared and its id is in the effects.

TypeScript
export function saleOpenTx(cfg: SaleRoomConfig, item: { id: string; type: string }, terms: SaleTerms)

On the live package room::open takes the Access object and the gate's Option<Membership> first. saleOpenTx passes cfg.access and an empty gate (the Access is PUBLIC on testnet); set terms.gate to a sender-bound pass minted for the Access object when it is not. SaleRoomConfig.access and the deployment record's accessId carry the id.

demoBadgeTx#

demo.move mint: a Badge to sell, sent to to.

TypeScript
export function demoBadgeTx(cfg: SaleRoomConfig, label: string, to: string)

finishRefusal#

room.move assert_finishable; null when finish would pass it.

TypeScript
export function finishRefusal(room: SaleRoomView, nowMs: number): string | null

expireRefusal#

room.move expire; null when it would pass.

TypeScript
export function expireRefusal(room: SaleRoomView, nowMs: number): string | null

sealApproveTx#

The dry run Seal's servers make before answering: room.move seal_approve, only after the close.

TypeScript
export function sealApproveTx(cfg: SaleRoomConfig, room: SaleRoomView)

finishShares#

Exactly threshold answers, in room.move KEY_SERVERS order: every share handed in costs finish gas per bid (room.move responder_keys needs at least THRESHOLD and verifies every one it gets).

TypeScript
export function finishShares(
  cfg: SaleRoomConfig,
  keys: Map<string, { toString(): string }>,
  servers?: number[],
): FinishShares

serverSubset#

Exactly threshold distinct indices into the room's KEY_SERVERS, ascending; anything else is refused.

TypeScript
export function serverSubset(
  cfg: Pick<SaleRoomConfig, "keyServers" | "threshold">,
  servers: number[],
): number[]

FinishOptions#

servers pins which key servers answer (indices into KEY_SERVERS, exactly threshold of them), say to use the committee server or to leave one out that is down. Without it, the first threshold servers in order that answer.

TypeScript
export type FinishOptions = { servers?: number[]; seal?: Pick<SealClient, "getDerivedKeys"> };

fetchFinishShares#

The room's derived keys from its key servers, under a session signer signs; refused before the close.

TypeScript
export async function fetchFinishShares(
  client: SuiGrpcClient,
  cfg: SaleRoomConfig,
  room: SaleRoomView,
  signer: Signer,
  opts: FinishOptions = {},
): Promise<FinishShares>

FINISH_COMPUTATION_CAP#

The protocol's max_gas_computation_bucket in computation units. Audit round 3: a 50-bid finish with all three keys is about 5.35M (address room) and 5.48M (shielded); with two, 4.548M measured and about 4.685M, so it hands two.

TypeScript
export const FINISH_COMPUTATION_CAP = 5_000_000n;

finishGasRefusal#

A finish dry run, judged before signing: null when it ran and fits the cap.

TypeScript
export function finishGasRefusal(
  dryRun: { ok: boolean; computationCost?: bigint; error?: string },
  gasPrice: bigint,
): { code: "OVER_GAS_CAP" | "INVALID_ARGUMENT"; why: string } | null

saleFinishTx#

TypeScript
export function saleFinishTx(cfg: SaleRoomConfig, room: SaleRoomView, shares: FinishShares, poolId: string)

saleExpireTx#

TypeScript
export function saleExpireTx(cfg: SaleRoomConfig, room: SaleRoomView)

SaleOutcome#

TypeScript
export type SaleOutcome = {
  digest: string;
  roomId: string;
  /** null: no valid bid; `address` null: a shielded bidder won. */
  winner: { address: string | null } | null;
  price: bigint;
  bids: number;
  valid: number;
  sharesHandedIn: number;
  /** Net change per address and coin in the finish transaction; the sender's includes its gas. */
  balanceChanges: { address: string; coinType: string; amount: bigint }[];
};

readSaleOutcome#

A landed finish of this package, read back: the RoomFinished event, the key shares it handed in, who got paid.

TypeScript
export async function readSaleOutcome(
  client: SuiGrpcClient,
  cfg: SaleRoomConfig,
  digest: string,
): Promise<SaleOutcome>

From sale-seller.ts#

Exported by index.ts.

The reader takes the key-share indices from the finish call's third argument, finish(pool, room, indices, derived, clock), which is the live package's layout.

SellerOptions#

TypeScript
export type SellerOptions = {
  chain: EsseyChain;
  signer: Signer;
  saleRoom: SaleRoomConfig;
  /** ShieldedPool<C> passed to room::finish so a shielded winner releases its reserved slot. */
  poolId: string;
};

EsseySeller#

A seller's wallet key on the sale-room package: mint the demo item, open a room, and end it. finish is the seller's after the close (room.move require_seller, abort 8). expire stays anyone's once the window has passed.

TypeScript
export class EsseySeller

EsseySeller methods#

EsseySeller.clockMs#

TypeScript
  async clockMs(): Promise<number>

EsseySeller.room#

TypeScript
  room(roomId: string): Promise<SaleRoomView>

EsseySeller.send#

TypeScript
  send(tx: Transaction, opts: { gasBudget?: bigint } = {}): Promise<Landed>

EsseySeller.mintBadge#

TypeScript
  async mintBadge(label: string): Promise<{ landed: Landed; badgeId: string }>

EsseySeller.open#

Any key+store object this wallet owns; refused before signing when room.move open would abort 10.

TypeScript
  async open(
    item: { id: string; type: string },
    terms: SaleTerms,
  ): Promise<{ landed: Landed; roomId: string }>

EsseySeller.finish#

The key servers' answers for the room, then room::finish with exactly THRESHOLD of them (opts.servers picks which).

TypeScript
  async finish(roomId: string, opts: FinishOptions = {}): Promise<Landed>

EsseySeller.expire#

A room nobody finished in its window: every deposit goes back and the item returns to the seller.

TypeScript
  async expire(roomId: string): Promise<Landed>

EsseySeller.outcome#

TypeScript
  outcome(finishDigest: string): Promise<SaleOutcome>

From shielded/wallet.ts#

Exported by index.ts.

Relayer#

A relayer and the smallest fee it takes (its MIN_FEE; anything less it refuses without sending).

TypeScript
export type Relayer = RelayerEndpoint & { minFee: bigint };

TESTNET_RELAYER#

The hosted testnet relayer, on the SUI pool's route. It serves POST /relay/<pool key>, one key per coin, and answers 404 for a bare /relay; the fee floor is that pool's own minFee. Both measured against the live service on 2026-11-05, and the address is the key it signs with.

TypeScript
export const TESTNET_RELAYER: Relayer = {
  url: "https://essey-relayer-production.up.railway.app/relay/sui",
  address: "0x85ca932022b8ebced6b9697a0a4bda0505dd589624b81ddf3b2b0b41c35a5149",
  minFee: 10_000_000n,
};

ShieldedSetup#

TypeScript
export type ShieldedSetup = {
  client: SuiGrpcClient;
  events: EventBcsReader;
  room: SaleRoomConfig;
  pool: ShieldedPoolConfig;
  relayer: Relayer;
  /** snarkjsProver over the circuit's wasm and zkey (prover.ts); the testnet key is a TEST-ONLY single-party setup. */
  prover?: Prover;
  /** circomlib's Poseidon over BN254; defaults to @mysten/sui/zklogin poseidonHash, which is the same function. */
  hash?: Hash;
  seal?: Pick<SealClient, "encrypt">;
  relayFetch?: typeof fetch;
  /**
   * Waits until the event reader has the relayer's transaction (EsseyChain.indexed): the relayer answers once the node
   * has it, and a scan before GraphQL catches up misses the change, so the next spend was refused (testnet, 2026-10-30).
   */
  indexed: (digest: string) => Promise<void>;
  /** This user's own addresses (wallets, agents): a private bid in a room one of them opened is refused. */
  ownAddresses?: string[];
  /**
   * Where recovered openings are kept. fromSeed with the same store finds a note whose ciphertext is later empty.
   * Omitted, the wallet keeps one in memory for this object only.
   */
  openings?: OpeningStore;
};

Scanned#

TypeScript
export type Scanned = { notes: OwnedNote[]; balance: bigint; state: WalletState; unopened: Unopened[] };

notes is every note this seed can open, spent ones included. An OwnedNote is the note (amount, pubkey, blinding) with its leaf index, its commitment, its nullifier, its spendKey and spent, true once the pool has published that nullifier. balance is the sum of the unspent notes' amounts, so after a full exit the spent notes are still listed and balance is 0n. state is the WalletState the composers take (state.keys is wallet.keys). unopened lists the pool's leaves this wallet could not open, { index, kind } with kind "empty" for a leaf with no ciphertext (a refund collect inserted) and "unreadable" for one this seed does not decrypt.

PrivateBid#

TypeScript
export type PrivateBid = { sent: Sent; bid: BuiltBid | null };

PrivateWithdraw#

TypeScript
export type PrivateWithdraw = { sent: Sent; withdraw: BuiltWithdraw | null };

ShieldedWallet#

A shielded wallet from one seed: every note, change and refund is found again by scanning the pool from the seed alone. Deposits are signed by a wallet that holds a pass; bids and withdraws leave only through a relayer.

TypeScript
export class ShieldedWallet

keys is a public property: the Keys derived from the seed (deriveKeys), with pubkey and encPub for a note made for this wallet, claimKey for claimSalt, and the spend and refund keys. (await wallet.scan()).state.keys is the same object; newDeposit(wallet.keys, amount) takes it.

TypeScript
  readonly keys: Keys;

ShieldedWallet methods#

ShieldedWallet.create#

TypeScript
  static create(o: ShieldedSetup): { wallet: ShieldedWallet; seed: Uint8Array }

ShieldedWallet.fromSeed#

TypeScript
  static fromSeed(seed: Uint8Array, o: ShieldedSetup): ShieldedWallet

ShieldedWallet.scan#

The whole pool's events, so the tree's root is the pool's and every refund collect inserted is found.

TypeScript
  async scan(): Promise<Scanned>

ShieldedWallet.depositTx#

The pass is the depositor's (pool.move deposit checks the membership is for this pool); the coin is amount + insert fee.

TypeScript
  async depositTx(
    depositor: string,
    pass: ProvedPass,
    amount: bigint,
    nowMs: number,
  ): Promise<{ tx: Transaction; deposit: Deposit; insertFee: bigint }>

A SUI deposit is split from gas. A USDC or tUSDsui deposit is drawn from the depositor's coins of the pool's type (coinWithBalance), and the emptied source coin is transferred back to the depositor in the same transaction.

The pass is proved for the pool, not for a room: room is the pool's id and nonce a fresh field element, so the tag differs on every deposit (from_proof takes the nonce with the pass, and deposit checks the membership names this pool):

TypeScript
const pass = await provedPassFor({ service, hash: poseidonHash, paths: bundle.membership, holder: depositor, room: TESTNET_POOL.pool, nonce: randomSalt(), secrets });
const { tx } = await wallet.depositTx(depositor, pass, 500_000_000n, Date.now());

randomSalt() is Sealed settlement v2's, a field element below R. deposit.note is the note this transaction inserts, made by newDeposit(wallet.keys, amount).

ShieldedWallet.bidRefusal#

room.move bid_from_pool's checks and the relayer's fee floor, before anything is sealed, proved or sent.

TypeScript
  bidRefusal(room: SaleRoomView, price: bigint, fee: bigint, nowMs: number): string | null

ShieldedWallet.bid#

A sealed bid paid from the pool, proved here and sent by the relayer; rescans and re-proves on a stale root.

TypeScript
  async bid(
    room: SaleRoomView,
    price: bigint,
    claimTo: string,
    nowMs: number,
    fee = this.#o.relayer.minFee,
  ): Promise<PrivateBid>

ShieldedWallet.withdraw#

amount to recipient through the relayer; the rest of the notes spent comes back as change (one insert fee).

TypeScript
  withdraw(recipient: string, amount: bigint, fee = this.#o.relayer.minFee): Promise<PrivateWithdraw>

ShieldedWallet.exit#

Everything left, to recipient: the one or two unspent notes, less the relayer's fee; inserts nothing.

TypeScript
  exit(recipient: string, fee = this.#o.relayer.minFee): Promise<PrivateWithdraw>

ShieldedWallet.claimSalt#

room.move claim's salt for a bid this seed made; recomputed from the seed and the bid's tag, never stored.

TypeScript
  claimSalt(tag: bigint): Uint8Array

From shielded/pool.ts#

Exported by index.ts.

ShieldedPoolConfig#

A shielded pool of the sale-room package: one per coin; levels is pool.move LEVELS.

TypeScript
export type ShieldedPoolConfig = { pkg: string; pool: string; coinType: string; levels: number };

TESTNET_POOL#

deployment.testnet.json pools[sui] (createPoolDigest 8bw7MwnG…), pool.move LEVELS :22. pkg here is the privacy package: pool moved there, so every pool::* call targets it.

TypeScript
export const TESTNET_POOL: ShieldedPoolConfig = {
  pkg: "0xef63ef732c30b87589ed9435a8291e72fed00f7bdc72a028196c244333c2464c",
  pool: "0x96db81b0f3cc2c804bb26fb835eaa7e41f73070e2153ed3e70ea1645d1707436",
  coinType: SUI,
  levels: 20,
};

PoolView#

TypeScript
export type PoolView = { insertFee: bigint; root: bigint; reserved: number; value: bigint };

readPool#

TypeScript
export async function readPool(client: SuiGrpcClient, cfg: ShieldedPoolConfig): Promise<PoolView>

EventBcsPage#

One page of a package event type as BCS, oldest first; after resumes from endCursor.

TypeScript
export type EventBcsPage = { bcs: Uint8Array[]; hasNextPage: boolean; endCursor: string | null };

EventBcsReader#

TypeScript
export type EventBcsReader = (eventType: string, after: string | null) => Promise<EventBcsPage>;

graphqlEventBcs#

TypeScript
export const graphqlEventBcs =
  (url: string): EventBcsReader =>

readPoolEvents#

Every NewCommitment and every NewNullifier of the package, filtered to this pool. Both, always: a wallet restored from its seed that skipped the nullifiers would show its spent notes as unspent (pool auditor, 2026-10-30).

TypeScript
export async function readPoolEvents(read: EventBcsReader, cfg: ShieldedPoolConfig): Promise<PoolEvents>

collectTx#

pool.move collect: anyone, once the room has finished or expired; one pending refund back into the tree.

TypeScript
export function collectTx(cfg: ShieldedPoolConfig, room: Pick<SaleRoomView, "id" | "itemType" | "coinType">)

claimTx#

room.move claim: anyone may send it; the item and the change go only to the claimTo the winning bid sealed.

TypeScript
export function claimTx(
  cfg: Pick<SaleRoomConfig, "pkg">,
  room: Pick<SaleRoomView, "id" | "itemType" | "coinType">,
  claimTo: string,
  salt: Uint8Array,
)