Metadata-Version: 2.4
Name: blockledger
Version: 0.1.0
Description-Content-Type: text/markdown
Requires-Dist: httpx>=0.24.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: click>=8.0.0
Requires-Dist: rich>=13.0.0
Requires-Dist: python-dotenv>=1.0.0
Dynamic: description
Dynamic: description-content-type
Dynamic: requires-dist

# BlockLedger Python SDK

> Blockchain verification for existing accounting systems (Tally, QuickBooks, SAP)

## Why BlockLedger?

**Accounting fraud costs $4.5 trillion annually.** Traditional accounting systems are single-party - only the company controls the ledger.

BlockLedger adds **multi-party blockchain verification** to your existing accounting workflow:
- Companies keep using Tally/QuickBooks/SAP
- Every transaction is verified by multiple organizations (company + auditor + regulator)
- Immutable audit trail - no one can alter past transactions
- Real-time compliance instead of annual audits

## Installation

```bash
pip install blockledger
```

## Quick Start

### 1. CLI Usage

```bash
# Setup
blockledger setup

# Import Tally CSV
blockledger import-csv vouchers.csv --token YOUR_JWT_TOKEN

# Verify transaction
blockledger verify PV-001 --token YOUR_JWT_TOKEN

# Demo mode
blockledger demo --count 10 --token YOUR_JWT_TOKEN
```

### 2. Python SDK

```python
from blockledger import BlockLedgerClient

# Initialize client
client = BlockLedgerClient(
    api_url="http://localhost:8000",
    token="your-jwt-token"
)

# Import Tally CSV
result = client.import_tally_csv("tally_export.csv")
print(f"Imported {result['imported']} transactions")

for tx in result['transactions']:
    print(f"Voucher: {tx['voucher_number']}")
    print(f"Blockchain Hash: {tx['blockchain_hash']}")
    print(f"TX ID: {tx['blockchain_tx_id']}")

# Verify on blockchain
verification = client.verify_transaction("PV-001")
if verification['verified']:
    print("✓ Transaction verified by all peers")
```

## For Tally Users (18M+ in India)

### Export from Tally to CSV

1. In Tally: Go to **Gateway of Tally → Display → Vouchers**
2. Select date range
3. Press **Alt+E** (Export)
4. Choose **Excel/CSV format**
5. Save as `vouchers.csv`

### Import to BlockLedger

```bash
blockledger import-csv vouchers.csv --token YOUR_TOKEN
```

That's it! Your transactions are now verified on Hyperledger Fabric blockchain with multi-party endorsement.

## Architecture

```
┌─────────────────┐
│  Your Company   │
│  Tally/SAP/QB   │
└────────┬────────┘
         │ CSV Export
         ↓
┌─────────────────┐
│  BlockLedger    │
│  API + SDK      │
└────────┬────────┘
         │
         ↓
┌────────────────────────────┐
│   Hyperledger Fabric       │
├────────────┬───────────────┤
│  Peer0.Org1│  Peer0.Org2   │
│  (Company) │  (Auditor)    │
│  ✓ Signs   │  ✓ Signs      │
└────────────┴───────────────┘
```

Each transaction requires **consensus from multiple organizations**:
- Company peer must sign
- Auditor peer must sign
- Optional: Regulator, tax authority, investors

**Result:** No single party can manipulate the ledger.

## CSV Format

```csv
date,voucher_number,description,account_debit,debit,account_credit,credit
2026-02-26,PV-001,Rent payment,Rent Expense,50000,Cash,50000
2026-02-26,RV-001,Cash sales,Cash,100000,Sales Revenue,100000
```

## Features

- ✅ **Multi-party verification** - Requires consensus from company + auditor
- ✅ **Immutable audit trail** - Blockchain prevents historical changes
- ✅ **Works with existing systems** - Doesn't replace Tally/QB/SAP
- ✅ **Real-time compliance** - Regulators see verified data instantly
- ✅ **Enterprise blockchain** - Built on Hyperledger Fabric
- ✅ **Cryptographic proof** - Every transaction has blockchain hash + TX ID

## Configuration

Set environment variables or create `.env`:

```bash
BLOCKLEDGER_API_URL=http://localhost:8000
BLOCKLEDGER_TOKEN=your-jwt-token
```

## Production Deployment

1. **Company runs Peer0.Org1** at their datacenter
2. **Auditor runs Peer0.Org2** at their infrastructure
3. **Regulator runs Peer0.Org3** (optional)
4. All peers communicate via Hyperledger Fabric gossip protocol
5. Backend API can run at company or neutral cloud (AWS/Azure)

## Requirements

- Python 3.9+
- BlockLedger backend (FastAPI)
- Hyperledger Fabric network (2+ peers)

## Links

- **Documentation**: https://blockledger.readthedocs.io
- **GitHub**: https://github.com/blockledger/blockledger
- **Backend Setup**: See `backend/README.md`
- **Fabric Setup**: See `fabric-network/README.md`

## License

MIT License - See LICENSE file

## Support

- Email: support@blockledger.io
- Issues: https://github.com/blockledger/blockledger/issues
- Slack: https://blockledger.slack.com

---

**Built for hackathon 2026** | Powered by Hyperledger Fabric
