Sub topic 15
Player-to-Player Trading Economies
Assume you understand sources, sinks, currencies, and basic rates. This chapter focuses on an economy where players exchange items or currency with one another. The main design problem is deciding what can be traded, how trades are matched, and how to prevent trading from creating unlimited wealth or unfair advantages.
What player trading changes
In a closed shop, the game controls both sides of a transaction. A player spends currency, and the game grants an item. In player trading, one player’s spending becomes another player’s income. The trade moves ownership between players, but it does not necessarily remove value from the economy.
For example, Alice sells a sword to Bob for 1,000 coins:
- Alice gains 1,000 coins.
- Bob loses 1,000 coins.
- The sword changes owner.
- The total number of coins does not change.
This makes trading a transfer system rather than a currency sink. If players can create valuable items or currency faster than they consume them, trading can expose and amplify inflation.
A trading system usually needs these decisions:
| Decision | Example choices | Main risk |
|---|---|---|
| Tradable objects | Items, currencies, crafting materials | Valuable items leave intended progression |
| Trade method | Direct trade, auction house, market orders | Scams, manipulation, or poor price discovery |
| Fee model | No fee, flat fee, percentage fee | Too little currency removal or excessive friction |
| Trade limits | Daily cap, level requirement, account age | Botting and duplicate-account abuse |
Choosing a market structure
Direct trading is simple and social. Two players agree on an exchange and confirm it. Both sides should see the final contents before accepting. The server, rather than the client, must validate ownership and complete the exchange atomically. Atomic means that either every part of the trade succeeds or none of it does.
An auction house gives players better price discovery. Sellers list items, and buyers search or place offers. It also creates a visible market price that can affect the perceived value of rewards. However, a market needs controls for expired listings, duplicate purchases, and price manipulation.
A useful rule is to keep the item and payment in escrow while a trade is pending. Escrow is temporary holding by the game server. It prevents a player from spending or listing the same asset twice.
def complete_trade(seller, buyer, item_id, price):
if price <= 0:
raise ValueError("price must be positive")
if item_id not in seller.items:
raise ValueError("seller does not own the item")
if buyer.coins < price:
raise ValueError("buyer cannot afford the trade")
buyer.coins -= price
seller.coins += price
seller.items.remove(item_id)
buyer.items.add(item_id)A production system also needs a transaction identifier, server-side locks, durable records, and recovery for interrupted requests. The example shows the intended state change, not the complete storage design.
Fees, fraud, and market health
A percentage transaction fee can act as a currency sink. A 5% fee on a 1,000-coin sale removes 50 coins while transferring 950 coins to the seller. The fee should be visible before confirmation so players can understand the result.
Protect the market with:
- Server-side ownership checks.
- One-time transaction identifiers to reject repeated requests.
- Rate limits on listings, searches, and purchases.
- Trade history for support investigations.
- Caps or delays on newly created accounts.
- Monitoring for repeated trades between the same accounts.
Track median prices, trade volume, unsold listings, fee currency removed, and the concentration of valuable items among accounts. A rising price alone does not prove inflation. Compare prices with player income and the amount of currency held by active players.
Exercise
A player sells an item for 2,000 coins with a 4% market fee. How many coins does the seller receive, and how many coins leave the economy?
Show answer
The seller receives 1,920 coins. The 80-coin fee leaves the economy if the fee is destroyed rather than paid to another player.