Skip to content

Trade

Two players trade directly: they open a trade, each puts items and money in on their own side, and each confirms. When both have confirmed, each side receives what the other put in. Either side may cancel while the trade is open, and each side then takes back what it put in. No fee is taken. Requires Inventory.

const deal = await rudder.trade.open({ partner: '01a1-…' });
await rudder.trade.pay({ trade: deal.trade, money: { asset: 'gold', amount: 200 } });
await rudder.trade.confirm({ trade: deal.trade });
FunctionKindCallerArgumentsResult
openmutationclient{partner}The trade, with its trade id
offermutationclient{trade, item, count?, id?}The trade
paymutationclient{trade, money}The trade
confirmmutationclient{trade}The trade
cancelmutationclient{trade}The trade
viewqueryclient{trade}The trade

open names the player on the other side; the caller is the first side. offer takes tradable goods out of the caller’s inventory into its side; count is how many of a stackable item (1 by default) and id names one unique piece instead of item. pay takes money out of the caller’s wallet into its side, in any asset, as often as the player likes.

A trade has trade (its id), status (open, settled or cancelled) and two sides in the order they were opened, each with player, goods, money, confirmed and claimed. The id is the only handle of a trade: the module does not list the trades of a player, and the other side is told nothing.

  • A side confirms what it sees. One confirmation settles nothing: the trade stays open with that side marked confirmed.
  • Any offer or pay by either side clears both confirmations, so nothing can be added under a side that has already confirmed.
  • When both sides have confirmed the trade settles: each side receives the other side’s goods and money.
  • cancel is allowed to either side while the trade is open, whatever is deposited, and always gives each side its own goods and money back. A trade is therefore never binding until it settles.
  • Deposits cannot be taken back one by one; undoing one means cancelling the whole trade.
  • Nothing expires: an open trade and its deposits wait until someone acts.
CodeMeaning
no_tradeThere is no such trade, or it is finished and both sides have collected.
not_partyThe player is not a side of the trade.
closedThe trade is settled or cancelled.
own_tradeA player does not trade with themselves.
invalid_amountAn amount of money must be positive.
insufficientThe player does not hold the money of pay.
unknown_item, not_tradable, invalid_count, not_enough, stack_fullFrom Inventory.
EventPayloadWhen
settled{trade}Both sides confirmed; each side collects the other’s deposit.
cancelled{trade}A side cancelled; each side collects its own deposit.
  • Activity: every open, offer, pay, confirm and cancel, with its arguments and how it ended.
  • No page of its own: a trade has no catalog. A player card shows the inventory and the wallet the goods and the money pass through.
  • No invite and no notification: the other player learns of a trade out of band, and a trade opened against a player who does not exist can only be cancelled.
  • No expiry and no timer: an abandoned trade keeps its deposits until someone cancels it.
  • If a side’s inventory is full when it collects, the goods wait until there is room.
  • The status of a trade is shown in code (open, settled, cancelled); the Dashboard has no labels for these values yet.