CSX Ledger-Based Utility Token PHP + MySQL

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

Primary architecture
Wallet + Transaction Ledger
Core operations
Reward / Transfer / Burn
Balance model
Controlled wallet updates
Safety layer
PDO Transactions (ACID)

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()

2. Transfer

Transfers tokens between two wallets.

Function: CsxWalletService::transferBetweenUsers()

3. Burn

Permanently destroys tokens.

Function: CsxWalletService::burnFromUser()

Database Structure

Table: csx_wallets

Stores wallet balances for users.

idWallet identifier
user_idOwner user
current_balanceCurrent token balance
statusWallet state
created_atCreation timestamp
updated_atLast update timestamp

Table: csx_transactions

Immutable ledger of all token operations.

idTransaction identifier
tx_uuidUnique transaction UUID
from_wallet_idSender wallet
to_wallet_idReceiver wallet
amountToken amount
typereward / transfer / burn
statusLedger status
referenceReference key
descriptionHuman-readable context
meta_jsonJSON metadata payload
created_byInitiator
created_atCreation timestamp

Transaction Types

reward → token mint
transfer → user transfer
burn → token destruction

Metadata System

Transactions can contain additional JSON metadata through the meta_json column.

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().

Parameters
  • from_wallet_id
  • to_wallet_id
  • amount
  • type
  • reference
  • description
  • meta_json
  • created_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:

  • positive values only
  • maximum 4 decimals
  • numeric format enforced

Transaction Safety

All token operations use PDO database transactions.

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.php
  • admin-csx-transfer-test.php
  • admin-csx-burn-test.php
  • test-csx.php

Example CLI Test

Returns:

  • wallet balance
  • wallet data
  • last transactions
  • decoded metadata

Page Views

This page has been viewed 16 times.