Skip to main content
forge-economy owns money. Wallets are write-through and audited: every change commits the balance and a log row in a single transaction, because money is the core of dupe forensics. On top of wallets it provides shops, proximity pay, and a full trade flow.

Concepts

  • Currency. A stable id (coin) with a scope (character or account), optional cap and decimals. The wallet owner is a character id or a user id depending on scope.
  • StartingBalances. Granted once on a character’s first activation.
  • Audited. Deposits, withdrawals, and transfers each write a balance change plus a ledger row atomically.

Exports

Wallets & currencies

ExportSignatureReturns
RegisterCurrencyRegisterCurrency(def)Result
GetBalanceGetBalance(owner, currency)Result{ data = { balance } }
CanAffordCanAfford(owner, currency, amount)boolean
DepositDeposit(owner, currency, amount, reason)Result
WithdrawWithdraw(owner, currency, amount, reason)Result
TransferTransfer(from, to, currency, amount, reason)Result (atomic)
OwnerForOwnerFor(character_id, currency)resolve the wallet owner id honoring scope
GetTransactionLogGetTransactionLog(owner, opts)the audit ledger

Shops, pay, trade

ExportSignature
RegisterShop / GetShop / OpenShopshop definitions and the buy/sell screen context
Buy / SellBuy(character_id, shop_id, slot, qty) / Sell(...)
PayPay(from, to, currency, amount), proximity player-to-player pay
RequestTrade / AcceptTrade / CancelTradetrade-window lifecycle
SetTradeOffer / LockTrade / ConfirmTradetwo-phase escrow commit
exports["forge-economy"]:Deposit(cid, "coin", 100, "starting")
local r = exports["forge-economy"]:GetBalance(cid, "coin")  -- r.data.balance == 100

Events

EventPayload
forge-economy:server:balanceChanged{ owner_id, currency, balance, delta, reason }
forge-economy:server:tradeCompleted / tradeCancelledtrade outcomes
Loot and quest currency rewards bridge into Deposit automatically.

Configuration

Ships one neutral currency, coin (character scope), plus StartingBalances = { coin = 100 }, in editable shared/data/currencies.lua (DefaultCurrencies / DefaultStartingBalances), gated by Config.ShipDefaults. Pay and trade distances and rate caps live in Config.