Skip to content

Market

A player lists tradable items at a price; any other player buys them at once, and the seller is paid when the sale happens. A lot that nobody buys can be taken back by the seller. The platform keeps a fee on every sale. Requires Inventory.

const sale = await rudder.market.sell({
item: 'iron-sword',
price: { asset: 'gold', amount: 120 },
});
await rudder.market.buy({ lot: sale.lot });

Develop → Modules → Market → Settings, one row for the project.

FieldMeaning
feeThe percent of the price the platform keeps, 0 to 100, 5 by default.

The buyer pays the price in full; the seller receives the price minus the fee of the moment of the sale.

FunctionKindCallerArgumentsResult
sellmutationclient{item, count?, id?, price}The sale, with its lot
buymutationclient{lot}What the buyer received: {item, count, ids}
cancelmutationclient{lot}What the seller took back
viewqueryclient{lot}The lot
browsequeryclientnone{lots}, at most 50 unsold lots

sell takes the goods out of the seller’s inventory and holds them for the lot. count is how many of a stackable item (1 by default); id names one unique piece instead of item; price is the amount and asset the buyer pays.

A lot has lot (its id), seller, goods, price and sold. It carries no buyer: a sale is finished for the buyer the moment buy answers, and the seller collects on their side.

  • The buyer pays as the sale happens and receives the goods in the same answer.
  • Once a lot is sold it cannot be cancelled; the seller collects the money.
  • cancel returns the goods to the seller’s inventory.
  • A lot never expires: it stays on the shelf until a player buys it or the seller cancels it.
  • If the buyer’s inventory is full the whole purchase is refused and the lot stays on the shelf; the buyer frees room and buys again.
  • Two players cannot both buy one lot: the second call answers sold.
CodeMeaning
no_lotThere is no such lot.
soldThe lot is already sold.
own_lotThe seller does not buy their own lot.
not_sellerOnly the seller cancels a lot.
invalid_priceThe price must be positive.
insufficientThe buyer does not hold the price.
unknown_item, not_tradable, invalid_count, not_enough, stack_fullFrom Inventory: the goods of sell, the buyer’s room or the seller’s room on cancel.
EventPayloadWhen
sold{lot}A buyer takes a lot; the money of the seller is on its way to the wallet.
  • Develop → Modules → Market → Settings: the fee.
  • Activity: every sell, buy and cancel, with its arguments and how it ended.
  • A player card shows the inventory and the wallet the goods and the money pass through.
  • No auction and no bidding: one price, first buyer wins.
  • No per-player limit on how many lots one seller opens, and no maximum price.
  • browse returns at most 50 unsold lots, the newest listings first. Older lots stay open and a known id still opens them with view, but a player browsing may not see them.
  • The goods of a lot sit outside the inventory until the sale or the cancel. A lot whose seller is deleted keeps its goods.