T2 // Economy & Business

coe_economy

ACID Economic Engine & Ledger

Atomic Double-Entry Financial Transactions with Multi-Currency Support

HEADLESS SERVICE (NO UI)
DEPENDS ON coe_corecoe_databasecoe_audit
coe_economy 25 exports · 2 commands

Runs without a NUI: nothing is rendered on the client and the resource stays idle until events arrive.

01 // OVERVIEW

The financial engine powering the entire COE Framework. Manages physical cash in pockets, checking accounts, savings, and interbank transfers. Every transaction strictly conforms to double-entry accounting principles, guaranteeing no currency is ever minted or lost without offsetting ledger entries.

On FiveM Enhanced

Asynchronous mathematical execution in MariaDB utilizing atomic row-level locks on Node.js 24 LTS / Node 26 (libnode26), eliminating race conditions during simultaneous cash withdrawals.

02 // FEATURES

What the module delivers

01

Double-Entry Accounting (ACID)

Every transaction credits one account and debits another with mathematical precision.

02

Multi-Wallet Architecture

Native support for Cash in Pockets, Bank Balances, and Escrowed Funds.

03

Zero Duplication Immunity

Atomic database row locks completely eliminate concurrent withdrawal exploits.

04

Automated Tax & Interest

Built-in scheduler for municipal sales tax and savings interest disbursements.

ARCHITECTURAL LAYERS // CLEAN ARCHITECTURE

4-Layer Isolation with 0.00 ms Idle

Every COE Framework script strictly follows the principle of separation of concerns. Interact with the 3D stack below:

L4
Headless Operation (No UI)
Zero DOM · CoE UI Delegation
Headless
L3
Application & Server
Atomic locks · Rate limiting
Auth Server
L2
Platform & HAL
Core.Platform · Mock natives
Gen9 HAL
L1
Domain & ACID Database
Prepared SQL · MariaDB pool
ACID Pool
LAYER 04 // HEADLESS SERVICE

Headless Service (No Dedicated NUI)

Operates strictly within layers L1–L3 (domain, HAL, and server-authoritative application logic). Visual interactions and management flows are delegated to centralized ecosystem apps (coe_ui / coe_tablet), guaranteeing 0.00 ms idle client overhead in FiveM DX12.

Zero CEF graphic overhead: no background web pages or NUI bridges loaded
Typed public contracts (types.lua) consumed directly by external resources and UIs
Strict adherence to the Server-Authoritative model with zero direct DOM manipulation
ADMIN POWERS // OPERATION & MANAGEMENT

What this script delivers to Server Owners

Manage your city without relying on developers. Runtime parameters, auditing, and ACE-protected commands:

🛡️
ACE Permissions
Administrative operations strictly protected by coe.staff and coe.admin principals.
IsPlayerAceAllowed(src, "coe.admin")
📊
Ledger Auditing
Relevant actions write audit records to the database through coe_audit.
exports.coe_audit:Record(severity, category, event, context)
⚡
0.00ms Idle Telemetry
Event-driven thread dispatch that stays dormant until network events fire.
Clean Architecture & HAL
03 // EXPORTS

Public API 25

Typed contracts to call from other resources. Full types live in types.lua and in the docs reference.

exports['coe_economy']:IsReady() → boolean

Returns whether economy persistence is ready and caller is authorized.

No parameters.

LUA
local result = exports['coe_economy']:IsReady()
exports['coe_economy']:Summary() → {

Returns total economy metrics (total accounts and aggregate balance). Requires `coe.economy.admin` ACE.

No parameters.

LUA
local result = exports['coe_economy']:Summary()
exports['coe_economy']:GetBalance(characterId) → integer|nil, string|nil

Current balance of character (account is provisioned with `StartingBalance` on first access).

ParameterType
characterIdinteger|string
LUA
local ok, detail = exports['coe_economy']:GetBalance(characterId)
exports['coe_economy']:GetFrozenBalance(characterId) → integer|nil, string|nil

Saldo bloqueado judicialmente na conta do personagem.

ParameterType
characterIdinteger|string
LUA
local ok, detail = exports['coe_economy']:GetFrozenBalance(characterId)
exports['coe_economy']:FreezeFunds(characterId, amount, reason, reference) → true|nil, string|nil

Congela judicialmente parte do saldo da conta do personagem sem impedir o uso do saldo restante.

ParameterType
characterIdinteger|string
amountinteger
reasonstring
referencestring|nil
LUA
local ok, detail = exports['coe_economy']:FreezeFunds(characterId, amount, reason, reference)
exports['coe_economy']:UnfreezeFunds(characterId, amount, reason, reference) → true|nil, string|nil

Desbloqueia saldo congelado judicialmente na conta do personagem.

ParameterType
characterIdinteger|string
amountinteger
reasonstring
referencestring|nil
LUA
local ok, detail = exports['coe_economy']:UnfreezeFunds(characterId, amount, reason, reference)
exports['coe_economy']:Credit(characterId, amount, reason, reference) → true|nil, string|nil

Credits money to character account respecting `MaxBalance` ceiling. Audited (`money_credited`).

ParameterType
characterIdinteger|string
amountinteger
reasonstring
referencestring|nil
LUA
local ok, detail = exports['coe_economy']:Credit(characterId, amount, reason, reference)
exports['coe_economy']:Debit(characterId, amount, reason, reference) → true|nil, string|nil

Debits money from character account; rejects if insufficient funds (strict atomic DB transaction). Audited (`money_debited`).

ParameterType
characterIdinteger|string
amountinteger
reasonstring
referencestring|nil
LUA
local ok, detail = exports['coe_economy']:Debit(characterId, amount, reason, reference)
exports['coe_economy']:Transfer(fromId, toId, amount, reason, reference) → true|nil, string|nil

Transfers money between two characters in a single atomic transaction. Audited (`money_transferred`).

ParameterType
fromIdinteger|string
toIdinteger|string
amountinteger
reasonstring
referencestring|nil
LUA
local ok, detail = exports['coe_economy']:Transfer(fromId, toId, amount, reason, reference)
exports['coe_economy']:Ledger(characterId, limit) → CoeEconomyLedgerRow[]|CoeEconomyError

Returns character transaction ledger, ordered newest first.

ParameterType
characterIdinteger|string
limitinteger|nil
LUA
local result = exports['coe_economy']:Ledger(characterId, limit)
exports['coe_economy']:LedgerStats(characterId, days, ignored) → {

Calculates ledger income and inflow metrics for the specified time window.

ParameterType
characterIdinteger|string
daysinteger|nil
ignoredstring[]|nil
LUA
local result = exports['coe_economy']:LedgerStats(characterId, days, ignored)
exports['coe_economy']:SocietyBalance(businessId) → integer|CoeEconomyError

Returns the available balance of a society / business account.

ParameterType
businessIdstring
LUA
local result = exports['coe_economy']:SocietyBalance(businessId)
exports['coe_economy']:SocietyLedger(businessId, limit) → table[]|CoeEconomyError

Returns transaction history for a society account.

ParameterType
businessIdstring
limitinteger|nil
LUA
local result = exports['coe_economy']:SocietyLedger(businessId, limit)
exports['coe_economy']:SocietyDeposit(businessId, characterId, amount) → true|CoeEconomyError

Deposits personal character funds into the society account. Restricted to business owner or staff (`not_staff`).

ParameterType
businessIdstring
characterIdinteger|string
amountinteger
LUA
local result = exports['coe_economy']:SocietyDeposit(businessId, characterId, amount)
exports['coe_economy']:SocietyWithdraw(businessId, characterId, amount) → true|CoeEconomyError

Withdraws society funds to character personal balance. Requires `business.funds` grade permission (owner has all).

ParameterType
businessIdstring
characterIdinteger|string
amountinteger
LUA
local result = exports['coe_economy']:SocietyWithdraw(businessId, characterId, amount)
exports['coe_economy']:SocietyCredit(businessId, amount, reason) → true|CoeEconomyError

Administrative deposit without character association. Requires `coe.economy.admin` ACE.

ParameterType
businessIdstring
amountinteger
reasonstring|nil
LUA
local result = exports['coe_economy']:SocietyCredit(businessId, amount, reason)
exports['coe_economy']:SocietyCollect(businessId, amount, reason) → true|CoeEconomyError

Revenue intake from customer payments (e.g. shop retail checkout). Requires `SocietyCollectors` or `coe.economy.society.collect` ACE.

ParameterType
businessIdstring
amountinteger
reasonstring
LUA
local result = exports['coe_economy']:SocietyCollect(businessId, amount, reason)
exports['coe_economy']:SocietyCharge(businessId, amount, reason, reference) → true|CoeEconomyError

Direct society business expense without character account (e.g. commercial rent). Requires `SocietyPayers` or `coe.economy.society.pay` ACE.

ParameterType
businessIdstring
amountinteger
reasonstring
referencestring|nil
LUA
local result = exports['coe_economy']:SocietyCharge(businessId, amount, reason, reference)
exports['coe_economy']:BankSocietyPay(businessId, characterId, amount, reason, reference) → true|CoeEconomyError

Transfers money from society account to a character personal account.

ParameterType
businessIdstring
characterIdinteger|string
amountinteger
reasonstring
referencestring|nil
LUA
local result = exports['coe_economy']:BankSocietyPay(businessId, characterId, amount, reason, reference)
exports['coe_economy']:BankSocietyDeposit(businessId, characterId, amount, reason, reference) → true|CoeEconomyError

Transfers money from a character personal account into the society account.

ParameterType
businessIdstring
characterIdinteger|string
amountinteger
reasonstring
referencestring|nil
LUA
local result = exports['coe_economy']:BankSocietyDeposit(businessId, characterId, amount, reason, reference)
exports['coe_economy']:BankSocietyDebit(businessId, amount, reason, reference) → true|CoeEconomyError

Outflow from society account without destination character (cash withdrawal, corporate card expense).

ParameterType
businessIdstring
amountinteger
reasonstring
referencestring|nil
LUA
local result = exports['coe_economy']:BankSocietyDebit(businessId, amount, reason, reference)
exports['coe_economy']:BankSocietyCredit(businessId, amount, reason, reference) → true|CoeEconomyError

Inflow into society account without origin character (cash deposit, reversal credit).

ParameterType
businessIdstring
amountinteger
reasonstring
referencestring|nil
LUA
local result = exports['coe_economy']:BankSocietyCredit(businessId, amount, reason, reference)
exports['coe_economy']:BankSocietyTransfer(fromId, toId, amount, reason, reference) → true|CoeEconomyError

B2B corporate transfer between two business accounts.

ParameterType
fromIdstring
toIdstring
amountinteger
reasonstring
referencestring|nil
LUA
local result = exports['coe_economy']:BankSocietyTransfer(fromId, toId, amount, reason, reference)
exports['coe_economy']:BankSocietyLedger(businessId, filter) → {

Filtered corporate transaction ledger with period aggregate totals.

ParameterType
businessIdstring
filter{
LUA
local result = exports['coe_economy']:BankSocietyLedger(businessId, filter)
exports['coe_economy']:RunPayroll(businessId) → CoeEconomyPayrollSummary|CoeEconomyError

Pays grade salary to characters currently on duty from the society account; if funds are insufficient, skips without incurring debt. Requires `coe.economy.admin` ACE or banker role. Emits local event `coe_economy:payrollPaid`.

ParameterType
businessIdstring
LUA
local result = exports['coe_economy']:RunPayroll(businessId)
04 // COMMANDS

In-game commands 2

/coe_economy_credit <stateId> <valor>

Administrative balance adjustment, recorded in the ledger. ACE command.coe_economy_credit.

/saldo

Shows the active character balance.