Back to Projects Gallery
Web3 & Smart ContractsOpen SourceTimeline: 2024Role: Smart Contract Developer & Security Researcher

Simple Ledger Contract — Auditor-First On-Chain Accounting

Translating double-entry accounting principles and financial control into on-chain Solidity invariants, validated through Socratic threat modeling.

The Problem

Smart contract vulnerabilities commonly stem from failure to establish core financial and balance invariants before coding, leading to reentrancy, unauthorized minting, and unauthorized state transitions.

The Architectural Solution

Designed a Solidity ledger contract founded on B.Sc. Accounting principles. Derived eight formal security invariants through structured threat analysis, modeling both insider and outsider threat actors to pressure-test contract logic before bytecode compilation.

System Architecture & Flow

CANONICAL TOPOLOGY
[Accounting Control Framework]
      │
      ├── Invariant Derivation: Non-negative balances, immutable journals, separation of duties
      ├── Attacker Threat Modeling: Malicious admin, compromised caller, outsider replay
      ▼
[Solidity Smart Contract (EVM)]
      ├── Access Control Modifiers: Strict role-based verification
      ├── Sequential State Transition (σ → σ'): Reentrancy guards, storage layout optimization
      └── Foundry & Hardhat Suite: Invariant property testing and local fork simulation

Engineering Contributions & Deliverables

  • Derived eight formal security invariants directly from classical double-entry accounting frameworks (non-negative balances, immutable audit logs, dual authorization for ledger reversals).
  • Modeled distinct threat actor profiles (malicious insiders, unprivileged callers, flash loan state disruptors) to audit attack vectors beforehand.
  • Implemented clean, gas-optimized Solidity code utilizing custom errors, storage packing, and immutable declarations.
  • Authored comprehensive property-based tests in Foundry and Hardhat simulating adversarial execution environments.

Formal Security Invariants Enforced

AUDITOR VERIFIED
[1]Balance Non-Negativity: No account balance may transition below zero under any execution path.
[2]Immutable Audit Trail: Prior journal entries are append-only and cannot be overwritten.
[3]Separation of Duties: High-risk administrative actions (reversals, freeze, role grant) require multi-signature or two-phase confirmation.
[4]Conservation of Value: Total debits must equal total credits in every atomic transfer transaction.

System Metrics

Security Invariants8 Formalized
MethodologyAuditor-First
Testing ToolchainFoundry & Hardhat
Accounting FrameworkDouble-Entry

Technology Breakdown

Core Runtime & Language
SolidityFoundryHardhat
Blockchain & Smart Contracts
Ethereum EVMEVM Storage LayoutState-Transition Model (σ)Gas Optimization
Backend & Protocols
Threat ModelingInvariant TestingAccess Control (RBAC)

Need a similar system designed?

I am available for contract development, smart contract auditing, and backend ledger architecture.

Hire Me for Your Project