Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

deliver

deliver<Name, Schema>(authority, source, receiver, deliverOptions): DeliverResult

Sends payload from source, a record this room holds, to receiver, a record any room or none may hold, as a deposit of its kind: inside a transact that takes the payload out of the source, so the two apply together or not at all. The room’s next checkpoint commits the source and the deposit in one transaction, and the receiver’s holder applies it through its onDepositReceive hook for the kind, now or when a room next opens it. An id already sent comes back to the source’s onDepositReturn hook, as does a deposit the receiver declines or cannot take. Refused, sending nothing, outside a transaction, for a source the room does not hold or that closes, past 20 sends a minute from a source or 5 to one receiver, for a payload or an id out of shape, and for a receiver with no onDepositReceive hook for the kind; in development, a call outside a transaction throws. deliver is not send*, which names a call from the client to the server.

Type Parameter
Name extends string
Schema extends SaveSchema
Parameter Type
authority Authority
source RecordHandle
receiver RecordHandle
deliverOptions DeliverOptions<Name, Schema>

DeliverResult

transact(step, () => {
spendCoins(step, player, 50);
const sent = deliver(step, records.player.for(playerId), guildBanks.for("42"), {
deposit: donation,
id: `donation-${playerId}-${day}`,
payload: { coins: 50 },
});
// A refused send gives the coins back with the rest.
if (!sent.isQueued) throw new Error(sent.refusal);
});