ConstOptionalageRestricted?: booleanOptionalgiftTo?: stringA gift: the buyer pays and is screened as usual, but the SKU is granted to this user id,
with no wallet-to-wallet credit or ownership transfer. Omitted (or equal to buyerId) for
a self-purchase.
const outcome = await economy.submit(spend({
idempotencyKey: idempotencyKey('order', 'ord_8821'),
actor: userActor('usr_buyer'),
orderId: 'ord_8821',
buyerId: 'usr_buyer',
sku: 'wrld_pass',
price: toAmount('CREDIT', 40_000n), // 400 credits
recipients: [{ sellerId: 'usr_seller', shareBps: 10_000 }],
}));
Builds a
spendoperation: a marketplace purchase that charges the buyer, pays the sellers, and grants theskuin one balanced transaction. The buyer'spromobalance is drawn first, thenspendable; each recipient'searnedaccount is credited its share of the net, and the platform fee plus any rounding leftover goes toREVENUE(the promo-funded part carries no fee). Rejects withINSUFFICIENT_FUNDS,FUNDS_IMMATURE(credits still in a settlement hold),DUPLICATE_ORDER(a sale already exists for thisorderIdunder a different key),RISK_DENIED, orECONOMY_PAUSED. Auseractor must be the buyer;systemandoperatoractors can buy on anyone's behalf.idempotencyKeydrops exact retries asduplicate, whileorderIdis the purchase's identity — the key a later refund names.