This project is a simulation of a blockchain designed to manage the tokenization of real-world financial assets like stocks and bonds. It provides a backend API and a web-based UI to interact with a custom-built blockchain that features cryptographic security and the ability to perform corporate actions like paying dividends.
Starting the Lesson?
Check out the Complete Student Guide for step-by-step instructions on running the simulation, from initializing wallets to settling trades.
- Custom Blockchain: Implemented from scratch in Python, featuring blocks, chains, and proof-of-work consensus.
- Persistent Database Layer (New):
- MongoDB: Stores blockchain state (blocks, transactions, ledgers).
- PostgreSQL: Stores user identity (KYC) and order book data.
- Asset Tokenization: Create and manage assets with rich metadata (e.g., stock tickers, bond maturity dates).
- Cryptographic Security: All transactions are secured using public/private key cryptography (ECDSA). Transactions must be signed by the asset owner.
- Client-Side Signing: The web UI handles all cryptographic operations (key generation and signing) directly in the browser.
- Smart Contracts (New):
- Programmable Logic: Deploy and interact with smart contracts like Escrow and Voting.
- Secure Simulation: Uses a restricted execution environment (simulated) for contract logic.
- Canton Network Domains (New):
- Privacy & Scalability: Assets can reside on different domains (
Global,Canton-US,Canton-EU). - Cross-Domain Transfers: Atomic movement of assets between domains.
- Privacy & Scalability: Assets can reside on different domains (
- DTCC Clearing & Settlement (New):
- On-Chain Netting: Trade intents are recorded on-chain, and a netting engine settles the net difference instantly (T-0).
- Deposit-to-Trade: Simulation of real-world clearing house mechanics where assets must be deposited to the CCP domain before trading.
- Corporate Actions:
- Dividend Payouts: Asset issuers can distribute payments to all current shareholders proportionally.
- Stock Splits: Multiply all shares by a ratio (e.g., 2-for-1 split) across all shareholders.
- Share Buybacks: Companies can repurchase shares from all holders proportionally at a specified price.
- Balance Checking: Query the balance of any asset for any wallet address.
- RESTful API & Web UI: A Flask-based API server exposes the blockchain functionality. The frontend is now a modern React application.
/
├── backend/
│ ├── app.py # Flask API server
│ ├── blockchain.py # Core Blockchain logic + Contract Engine
│ ├── contracts.py # Smart Contract templates (Escrow, Voting)
│ ├── wallet.py # Wallet class (ECDSA)
│ └── requirements.txt # Python dependencies
└── frontend/ # React + Tailwind UI
├── src/ # React source code
├── public/ # Static assets
└── package.json # Node.js dependencies
This project requires MongoDB and PostgreSQL to be running locally.
- MongoDB: Port 27017 (Default).
- PostgreSQL: Port 5432 (Default). Database
compliance_exchangewill be auto-created.- Note: Update
backend/.envif your Postgres credentials differ from the default.
- Note: Update
The backend is a Flask server that runs the blockchain logic.
- Navigate to the
backenddirectory:cd backend - Install the required Python dependencies:
pip install -r requirements.txt
- Run the Flask application:
python app.py
The server will start on http://localhost:5001.
The frontend is a modern React application. You need Node.js installed.
- Open a new, separate terminal.
- Navigate to the
frontenddirectory:cd frontend - Install dependencies (first time only):
npm install
- Start the development server:
npm run dev
- Open the link shown in the terminal (usually
http://localhost:5173).
A standard escrow contract where funds are held until an arbiter releases them.
- Deploy: Template
Escrow. Args:{"arbiter": "PUBKEY", "beneficiary": "PUBKEY", "asset_name": "CASH", "amount": 50}. - Fund: Send
CASHto the generated Contract Address using a standard Transfer. - Release: The Arbiter calls method
releaseto send funds to the beneficiary.
A proposal-based voting system.
- Deploy: Template
Voting. - Create Proposal: Owner calls
create_proposalwith{"description": "Buy more servers"}. - Vote: Token holders call
votewith{"proposal_id": "1"}. Voting weight is based on theirGEM-STOCKbalance.
Move assets between privacy domains (e.g., Global -> Canton-US).
- Go to Market & Assets -> Transfer.
- Enable Cross-Domain Transfer.
- Select Source (
Global) and Destination (Canton-US) domains. - The asset will disappear from the Global ledger and appear in the Canton-US private ledger.
Simulate instant trade settlement via a clearing house.
- Deposit: Move assets to the
DTCC-Clearingdomain (using Cross-Domain Transfer above). - Trade: Go to DTCC Clearing page and submit a
SELLorder. - Settle: Click Run Netting & Settle. The system calculates net obligations and settles them On-Chain in a single transaction.
This simulation is designed to be a highly realistic representation of the Institutional Blockchain (Capital Markets) revolution currently occurring in the financial sector. It strips away "crypto hype" to focus on the structural efficiency gains that banks and regulators care about.
| Concept in Simulation | Real-World Equivalent | Explanation |
|---|---|---|
| GSCOIN vs. CASH | JPM Coin / RLN | Banks do not settle in volatile crypto assets. They settle in Tokenized Deposits (Commercial Bank Money). The simulation's separation of "Value Tokens" (GSCOIN) from "Gas Tokens" (CASH) mirrors the Regulated Liability Network. |
| DTCC Domain (Netting) | Project Ion (DTCC) | The move from T+2 to T-0 Settlement is the biggest operational shift in finance. The simulation's netting engine demonstrates how blockchain can act as the "Golden Source of Truth" for clearing, eliminating reconciliation costs. |
| Atomic Swaps (DvP) | Canton Network | Delivery vs. Payment (DvP) without a central counterparty eliminates settlement risk (Herstatt Risk). This is the core value proposition of inter-bank ledger interoperability projects like Canton. |
| Collateralized Loans | Project Guardian | Institutions are piloting Intraday Repo markets where they tokenize Treasuries to borrow cash for hours. The simulation's "DeFi Lending" contract is a simplified model of these institutional credit facilities. |
Verdict: This project teaches the workflows of a Digital Asset Architect at a Tier-1 Bank, rather than a retail crypto trader. It focuses on the three pillars of enterprise blockchain: Privacy (Domains), Finality (Settlement), and Interoperability (Atomic Swaps).