Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Built with Rust and ink! for Substrate/Polkadot ecosystem, these smart contracts
## 🚀 Features

### Core Capabilities

- **🏠 Asset Tokenization**: Transform physical real estate properties into tradable NFTs with legal compliance
- **💰 Secure Transfers**: Multi-signature property transfers with escrow protection
- **🔗 Property Registry**: On-chain property ownership registry with metadata storage
Expand All @@ -17,15 +18,18 @@ Built with Rust and ink! for Substrate/Polkadot ecosystem, these smart contracts
- **💾 On-chain Storage**: Decentralized storage for property documents and metadata

### Advanced Features

- **⛓️ Cross-Chain Compatibility**: Designed for Substrate/Polkadot ecosystem with EVM compatibility
- **📈 Property Valuation**: On-chain valuation oracle integration for real-time pricing
- **🔍 Property Discovery**: Efficient on-chain search and filtering capabilities
- **📱 Mobile Integration**: Lightweight contract interfaces for mobile dApps
- **🛡️ Security First**: Formal verification and comprehensive audit coverage
- **📅 Tax Compliance**: Automated tax calculation, payments, and deadline notifications

## 👥 Target Audience

This smart contract system is designed for:

- **Real Estate Tech Companies** building blockchain-based property platforms
- **Property Investment Firms** seeking fractional ownership solutions
- **Blockchain Developers** creating DeFi real estate applications on Substrate
Expand All @@ -35,7 +39,9 @@ This smart contract system is designed for:
## 🛠️ Quick Start

### Prerequisites

Ensure you have the following installed:

- **Rust** 1.70+ (stable toolchain)
- **ink! CLI** for smart contract development
- **Substrate Node** for local testing
Expand Down Expand Up @@ -69,20 +75,23 @@ The contracts will be compiled and ready for deployment to Substrate-based netwo
## 🚀 Development & Deployment

### Development Environment

```bash
./scripts/build.sh # Build contracts in debug mode
./scripts/test.sh # Run unit tests
cargo test # Run all tests including integration
```

### Production Deployment

```bash
./scripts/build.sh --release # Build optimized contracts
./scripts/deploy.sh --network westend # Deploy to testnet
./scripts/deploy.sh --network polkadot # Deploy to mainnet
```

### Testing Suite

```bash
./scripts/test.sh # Run all tests
./scripts/test.sh --coverage # Run with coverage
Expand All @@ -99,12 +108,14 @@ For comprehensive load testing documentation, see [Load Testing Guide](docs/LOAD
## 🌐 Network Configuration

### Supported Blockchains

- **Polkadot** (Mainnet, Westend Testnet)
- **Kusama** (Mainnet)
- **Substrate-based Parachains** (Custom networks)
- **Local Development** (Substrate Node)

### Environment Configuration

```env
# Network
NETWORK=westend
Expand All @@ -122,6 +133,7 @@ TARGET=wasm32-unknown-unknown
## 📚 Documentation & Resources

### 🏗️ Architecture Documentation (NEW!)

- **[📋 Architecture Index](./docs/ARCHITECTURE_INDEX.md)** - Complete guide to all architecture docs
- **[🌐 System Architecture Overview](./docs/SYSTEM_ARCHITECTURE_OVERVIEW.md)** - High-level system design and components
- **[🔗 Component Interaction Diagrams](./docs/COMPONENT_INTERACTION_DIAGRAMS.md)** - Detailed interaction sequences
Expand All @@ -130,22 +142,26 @@ TARGET=wasm32-unknown-unknown
- **[📝 Documentation Maintenance](./docs/ARCHITECTURE_DOCUMENTATION_MAINTENANCE.md)** - How we keep docs current

### Contract Documentation

- **[📖 Contract API](./docs/contracts.md)** - Complete contract interface documentation
- **[🔗 Integration Guide](./docs/integration.md)** - How to integrate with frontend applications
- **[🚀 Deployment Guide](./docs/deployment.md)** - Contract deployment best practices
- **[🏗️ Architecture](./docs/architecture.md)** - Contract design and technical architecture

### Frontend SDK

- **[📦 Frontend SDK](./sdk/frontend/)** - TypeScript SDK for dApp integration
- **[📖 Frontend SDK Guide](./docs/FRONTEND_SDK_GUIDE.md)** - Comprehensive usage guide with API reference
- **[💻 Example React App](./sdk/frontend/examples/react-app/)** - Working Vite + React example

### Development Documentation

- **[🛠️ Development Setup](./DEVELOPMENT.md)** - Complete development environment setup
- **[📋 Contributing Guide](./CONTRIBUTING.md)** - How to contribute effectively
- **[🎓 Tutorials](./docs/tutorials/)** - Step-by-step integration tutorials

### Repository Structure

```
PropChain-contract/
├── 📁 contracts/ # Main smart contract source code
Expand All @@ -169,24 +185,28 @@ PropChain-contract/
## 🛠️ Technology Stack

### Smart Contract Development

- **🦀 Language**: Rust - Memory safety and performance
- **⚡ Framework**: ink! - Substrate smart contract framework
- **⛓️ Platform**: Substrate/Polkadot - Enterprise blockchain framework
- **🔗 WASM**: WebAssembly compilation for blockchain deployment

### Development Tools

- **🛠️ Build**: Cargo - Rust package manager and build system
- **🧪 Testing**: Built-in Rust testing framework + ink! testing
- **📖 Documentation**: rustdoc - Auto-generated documentation
- **🔄 CI/CD**: GitHub Actions - Automated testing and deployment

### Blockchain Infrastructure

- **⛓️ Networks**: Polkadot, Kusama, Substrate parachains
- **🔐 Wallets**: Polkadot.js, Substrate-native wallets
- **📊 Oracles**: Chainlink, Substrate price feeds
- **🔍 Explorers**: Subscan, Polkadot.js explorer

### Security & Verification

- **🛡️ Security**: Formal verification with cargo-contract
- **🔍 Auditing**: Comprehensive security audit process
- **📋 Standards**: ERC-721/1155 compatibility layers
Expand All @@ -195,6 +215,7 @@ PropChain-contract/
## 🏆 Project Status

### ✅ Completed Features

- [x] Property Registry Contract
- [x] Escrow System
- [x] Token Contract (ERC-721 compatible)
Expand All @@ -205,28 +226,32 @@ PropChain-contract/
- [x] Documentation

### 🚧 In Progress

- [ ] Oracle Integration
- [ ] Cross-chain Bridge
- [ ] Mobile SDK
- [ ] Advanced Analytics

### ✅ Recently Completed

- [x] Frontend SDK with TypeScript support
- [x] Example React frontend application
- [x] Frontend integration testing
- [x] Frontend SDK documentation

### 📋 Planned Features

- [ ] Governance System
- [ ] Insurance Integration
- [ ] Mortgage Lending Protocol
- [ ] Property Marketplace

## 🤝 Contributing

We welcome contributions! Please read our [Contributing Guide](./CONTRIBUTING.md) to get started.
We welcome contributions! Please read our [Contributing Guide](./CONTRIBUTING.md) to get started.

**Quick contribution steps:**

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Run tests (`./scripts/test.sh`)
Expand All @@ -241,12 +266,14 @@ This project is licensed under the **MIT License** - see the [LICENSE](LICENSE)
## 🤝 Support & Community

### Get Help

- **🐛 Report Issues**: [GitHub Issues](https://github.com/MettaChain/PropChain-contract/issues)
- **📧 Email Support**: contracts@propchain.io
- **📖 Documentation**: [docs.propchain.io](https://docs.propchain.io)
- **💬 Discord**: [PropChain Community](https://discord.gg/propchain)

### Additional Resources

- **[🌐 Frontend Application](https://github.com/MettaChain/PropChain-FrontEnd)** - Client-side React/Next.js application
- **[🔒 Security Audits](./audits/)** - Third-party security audit reports
- **[📊 Performance Metrics](./docs/performance.md)** - Benchmarks and optimization guides
Expand Down
14 changes: 14 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# TODO: Implement Tax Deadline Notifications

## Plan Steps (Approved)

1. [x] Update contracts/tax-compliance/src/tax_engine.rs: Add `days_until_due` helper function.
2. [x] Update contracts/tax-compliance/src/lib.rs: Add events `TaxDeadlineApproaching`, `TaxDeadlineNotification`; emit in `calculate_tax()` and `check_compliance()`.
3. [x] Update contracts/tax-compliance/src/compliance.rs: No changes needed (generate_alerts already supports PaymentDueSoon/TaxOverdue).
4. [x] Update docs/compliance-regulatory-framework.md: Document new features.
5. [x] Update README.md: Add feature mention.
6. [ ] Add/update tests in contracts/tax-compliance/src/lib.rs.
7. [ ] Run `cargo test` and `./scripts/test.sh`.
8. [ ] Complete task.

Progress will be updated after each step.
7 changes: 7 additions & 0 deletions contracts/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,15 @@ pub mod propchain_contracts {

/// Reentrancy protection guard
reentrancy_guard: ReentrancyGuard,

/// Circuit breaker configuration for external calls
external_call_config: CircuitBreakerConfig,

/// Circuit breaker states for each external dependency
external_call_breakers: Mapping<ExternalDependency, CircuitBreakerState>,
}


/// Escrow information
#[derive(
Debug, Clone, PartialEq, scale::Encode, scale::Decode, ink::storage::traits::StorageLayout,
Expand Down
98 changes: 87 additions & 11 deletions contracts/tax-compliance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,47 @@ mod tax_compliance {
verified: bool,
}

#[ink(event)]
pub struct ComplianceRegistrySyncRequested {
#[ink(topic)]
property_id: u64,
#[ink(topic)]
jurisdiction_code: u32,
reporting_period: u64,
outstanding_tax: Balance,
legal_documents_verified: bool,
reporting_submitted: bool,
}
#[ink(event)]
pub struct ComplianceRegistrySyncRequested {
#[ink(topic)]
property_id: u64,
#[ink(topic)]
jurisdiction_code: u32,
reporting_period: u64,
outstanding_tax: Balance,
legal_documents_verified: bool,
reporting_submitted: bool,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum DeadlineAlertLevel {
Approaching,
Urgent,
}

#[ink(event)]
pub struct TaxDeadlineApproaching {
#[ink(topic)]
property_id: u64,
#[ink(topic)]
jurisdiction_code: u32,
reporting_period: u64,
due_at: Timestamp,
days_remaining: u16,
alert_level: DeadlineAlertLevel,
}

#[ink(event)]
pub struct TaxDeadlineNotification {
#[ink(topic)]
property_id: u64,
#[ink(topic)]
jurisdiction_code: u32,
reporting_period: u64,
due_at: Timestamp,
days_remaining: u16,
}

#[ink(event)]
pub struct TaxDocumentUploaded {
Expand Down Expand Up @@ -555,6 +585,28 @@ mod tax_compliance {
tax_due,
});

// Emit tax deadline notification if approaching
if let Some(days) = crate::tax_engine::days_until_due(now, record.due_at) {
if days <= 30 {
let alert_level = if days <= 7 { DeadlineAlertLevel::Urgent } else { DeadlineAlertLevel::Approaching };
self.env().emit_event(TaxDeadlineApproaching {
property_id,
jurisdiction_code: jurisdiction.code,
reporting_period,
due_at: record.due_at,
days_remaining: days,
alert_level,
});
self.env().emit_event(TaxDeadlineNotification {
property_id,
jurisdiction_code: jurisdiction.code,
reporting_period,
due_at: record.due_at,
days_remaining: days,
});
}
}

let snapshot = self.build_snapshot(
property_id,
jurisdiction.code,
Expand Down Expand Up @@ -758,6 +810,30 @@ mod tax_compliance {
let snapshot =
self.build_snapshot(property_id, jurisdiction.code, &rule, &assessment, record);

// Emit tax deadline notification if approaching during compliance check
if let Some(record) = record {
if let Some(days) = crate::tax_engine::days_until_due(now, record.due_at) {
if days <= 30 {
let alert_level = if days <= 7 { DeadlineAlertLevel::Urgent } else { DeadlineAlertLevel::Approaching };
self.env().emit_event(TaxDeadlineApproaching {
property_id,
jurisdiction_code: jurisdiction.code,
reporting_period: record.reporting_period,
due_at: record.due_at,
days_remaining: days,
alert_level,
});
self.env().emit_event(TaxDeadlineNotification {
property_id,
jurisdiction_code: jurisdiction.code,
reporting_period: record.reporting_period,
due_at: record.due_at,
days_remaining: days,
});
}
}
}

let mut outstanding_ref = [0u8; 32];
outstanding_ref[16..].copy_from_slice(&snapshot.outstanding_tax.to_be_bytes());

Expand Down
9 changes: 9 additions & 0 deletions contracts/tax-compliance/src/tax_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,12 @@ pub(crate) fn resolve_status(record: TaxRecord, now: Timestamp) -> TaxStatus {
TaxStatus::Assessed
}
}

pub(crate) fn days_until_due(now: Timestamp, due_at: Timestamp) -> Option<u16> {
if due_at <= now {
return None;
}
let millis_per_day = 24 * 60 * 60 * 1000u64;
let days = ((due_at - now) / millis_per_day) as u16;
Some(days)
}
Loading
Loading