CryptoSmartX Token Architecture
CSX is an internal ledger-based utility token built around a wallet and immutable transaction ledger architecture.
Every token movement is recorded as a permanent backend transaction. Balances are controlled through ACID-safe wallet updates and are never derived from uncontrolled manual edits.
Core model
Name: CryptoSmartX Token
Symbol: CSX
Type: Internal ledger-based utility token
Backend: PHP + MySQL
Project Overview
The CryptoSmartX Token is implemented as an internal ledger-based utility token. Every movement of value is written to an immutable transaction log and wallet balances are updated only through controlled backend service methods.
This architecture prioritizes traceability, deterministic balance control, operational safety and backend auditability over ad hoc balance mutation.
Core principle
Every token movement is a transaction first and a balance change second.
The ledger acts as the permanent source of operational truth while wallet balances are adjusted in tightly controlled database transactions.
Token Operations
1. Reward
Creates tokens and assigns them to a wallet.
Function: CsxWalletService::rewardUser()
SYSTEM
↓
INSERT transaction (reward)
↓
increase wallet balance
2. Transfer
Transfers tokens between two wallets.
Function: CsxWalletService::transferBetweenUsers()
Sender wallet
↓
INSERT transfer transaction
↓
decrease sender balance
↓
increase receiver balance
3. Burn
Permanently destroys tokens.
Function: CsxWalletService::burnFromUser()
Wallet
↓
INSERT burn transaction
↓
decrease wallet balance
Database Structure
Table: csx_wallets
Stores wallet balances for users.
| id | Wallet identifier |
| user_id | Owner user |
| current_balance | Current token balance |
| status | Wallet state |
| created_at | Creation timestamp |
| updated_at | Last update timestamp |
Table: csx_transactions
Immutable ledger of all token operations.
| id | Transaction identifier |
| tx_uuid | Unique transaction UUID |
| from_wallet_id | Sender wallet |
| to_wallet_id | Receiver wallet |
| amount | Token amount |
| type | reward / transfer / burn |
| status | Ledger status |
| reference | Reference key |
| description | Human-readable context |
| meta_json | JSON metadata payload |
| created_by | Initiator |
| created_at | Creation timestamp |
Transaction Types
Metadata System
Transactions can contain additional JSON metadata through the meta_json column.
{
"source": "admin_test",
"trigger": "manual_transfer",
"note": "Test transfer with meta_json"
}
Metadata is decoded automatically in the backend as meta_json_decoded.
Backend Service
Core class: CsxWalletService
- wallet creation
- balance management
- token minting
- transfers
- burns
- transaction logging
- metadata handling
Key Methods
getOrCreateWalletByUserId()getWalletByUserId()getBalanceByUserId()rewardUser()transferBetweenUsers()burnFromUser()getTransactionsByUserId()
Transaction Insertion
All ledger writes are centralized through insertTransaction().
from_wallet_idto_wallet_idamounttypereferencedescriptionmeta_jsoncreated_by
Balance Control
Balance updates are centralized through adjustWalletBalance().
Operators
adjustWalletBalance(walletId, amount, '+')
adjustWalletBalance(walletId, amount, '-')
Balance Validation
Before transfers or burns the system checks hasSufficientBalance().
This ensures the wallet balance is greater than or equal to the requested amount.
Input Validation
Amounts must match the following validation pattern:
/^\d+(\.\d{1,4})?$/
- positive values only
- maximum 4 decimals
- numeric format enforced
Transaction Safety
All token operations use PDO database transactions.
beginTransaction();
try {
insertTransaction();
adjustWalletBalance();
commit();
} catch (\Throwable $e) {
rollBack();
throw $e;
}
Auditability
Every token movement creates a permanent record in csx_transactions.
- complete token history
- audit trail
- forensic traceability
Wallet Creation
Wallets are created lazily when a user first interacts with the token system.
Method: getOrCreateWalletByUserId()
Token Supply Model
- Minting:
rewardUser() - Circulation:
transferBetweenUsers() - Deflation:
burnFromUser()
Security Design
- ACID database transactions
- strict input validation
- immutable transaction ledger
- centralized balance control
- audit metadata support
Testing System
admin-csx-reward-test.phpadmin-csx-transfer-test.phpadmin-csx-burn-test.phptest-csx.php
Example CLI Test
php test-csx.php 1
Returns:
- wallet balance
- wallet data
- last transactions
- decoded metadata
Page Views
This page has been viewed 16 times.