RevFramework – Sample Scene: 05_Currency_Escrow¶
Goal¶
Teach the hard-hold escrow lifecycle:
TryHold debits now → token returned → Commit keeps the debit or Release refunds it → optional TTL expiry resolves stale holds.
What This Scene Demonstrates¶
This scene shows escrow as a capability on the composed currency service stack.
The flow is:
Owner → ICurrencyService → ICurrencyEscrow → TryHold → token → Commit / Release / ExpireStale
- Escrow must be present on the resolved service stack
TryHolddebits the wallet immediately- A successful hold returns a token
Commitresolves the token and keeps the debitReleaseresolves the token and refunds the held amount- A positive TTL can be processed later by
ExpireStaleor an expiry pump - The local holds list only shows tokens created by this panel
Escrow is real service behaviour.
The service result is truth.
What To Look For¶
Use the CurrencyEscrowPanel to follow the hold lifecycle from creation to resolution.
-
Setup tab
-
Owner is the wallet receiving holds
- Service shows the resolved
ICurrencyServicestack - Escrow shows whether
ICurrencyEscrowis present - Pump shows whether a
CurrencyEscrowExpiryPumpis attached -
Reason / SourceId are passed into escrow operations
-
Currency
-
Selects which
CurrencyDefinitioncan be held - Resolves the selected
CurrencyId -
Shows the live owner balance before and after holds
-
Hold Inputs
-
Amount controls how much currency is reserved
- TTL controls how long the hold can live before expiry processing
- TTL of
0means no automatic expiry -
Try Hold calls
TryHoldand debits immediately when successful -
Holds tab
-
Shows tokens created by this panel
- Shows token, currency, amount, and age/TTL
- Commit keeps the debit
-
Release refunds the held amount
-
Pump tab
-
Can add or remove a local
CurrencyEscrowExpiryPump - Can adjust pump interval
- Manual
ExpireStaletriggers expiry processing immediately
Sample Scope¶
This scene covers:
- Detecting
ICurrencyEscrowon the active service stack - Creating hard holds with
TryHold - Resolving holds with
CommitandRelease - TTL-based expiry concepts
- Manual expiry through
ExpireStale - Optional expiry pumping through
CurrencyEscrowExpiryPump - Verifying changes through live wallet balance and returned results
This scene does NOT cover:
- Full checkout system design
- Crafting reservation flows in depth
- Persisting escrow tokens across scene loads
- Network-safe token ownership
- Production cleanup policies
- Multiplayer replication or networking
Those are project-level integration concerns.
Authority Note¶
This scene may include a permissive sample authority setup so it runs without additional configuration.
Networking Reminder¶
RevFramework does not include networking.
For multiplayer projects, escrow requests, commits, releases, and expiry decisions must be validated and executed through your own authority and networking layer.
How To Use¶
- Enter Play Mode.
- Toggle the
CurrencyEscrowPanelwithF8. -
In Setup:
-
Confirm Owner is assigned
- Confirm
ICurrencyServiceis resolved - Confirm Escrow is present
- Use another panel or gameplay to give the owner enough currency for a hold.
- Select a currency.
- Enter a hold amount.
- Optionally enter a TTL in seconds.
- Press Try Hold.
- Confirm the live balance drops immediately.
-
Open Holds:
- Press Commit to keep the debit
- Press Release to refund the held amount
-
Open Pump:
-
Add a pump if needed
- Adjust the interval if needed
- Press ExpireStale manually to process stale holds immediately
Failure Behaviour¶
Failures are shown through dependency messages, hold results, token results, or expiry results.
Common causes:
-
Play Mode required
-
Escrow holds and TTL expiry run against live wallet state
-
Fix: enter Play Mode
-
Service missing
-
No
ICurrencyServicewas resolved -
Fix: add
SceneCurrencyService, addCurrencyServiceBootstrap, or publish a composed service -
Escrow not composed
-
The resolved service stack does not expose
ICurrencyEscrow -
Fix: compose escrow support using the appropriate currency factory/bootstrap setup
-
Owner missing
-
No wallet owner is selected
-
Fix: assign an owner or tag the player GameObject as
Player -
No currencies bound
-
No
CurrencyDefinitionassets are available for holds -
Fix: assign currencies in the Inspector or provide a
CurrencySet -
Invalid CurrencyId
-
The selected
CurrencyDefinitionhas an invalid Id -
Fix: correct the CurrencyDefinition asset
-
Invalid hold amount
-
Hold amount must be greater than zero
-
Fix: enter a positive amount
-
Hold failed
-
The service rejected the hard hold
-
Fix: check owner balance, escrow composition, caps/policy, authority, and selected currency
-
Commit or Release failed
-
The token could not be resolved
-
Fix: the token may already be committed, released, expired, or unknown to the escrow service
-
Expired token still appears locally
-
The local holds list only tracks tokens created by this panel
- Fix: trust the escrow result; the local list is not a full escrow database view
Behind The Scenes¶
The panel uses real Currency escrow APIs:
-
CurrencyResolve.ServiceFrom -
resolves the active
ICurrencyService -
CurrencyFactories.TryGetEscrow -
detects
ICurrencyEscrowon the composed service stack -
ICurrencyEscrow -
TryHold CommitRelease-
ExpireStale -
CurrencyEscrowExpiryPump -
periodically calls expiry processing on the escrow service
-
ICurrencyService -
provides the live wallet state used to verify escrow effects
The panel does not inspect escrow internals.
The local holds list is only a teaching list of tokens created here.
The escrow service decides whether each token operation succeeds.
Key Takeaway¶
Escrow is a hard hold.
TryHold reserves currency by debiting it immediately.
Commit keeps the debit, Release refunds it, and expiry processing resolves stale holds.