Internal development guide for the TTM4195 project.
- System: A blockchain-based leasing system using a self-executing smart contract.
- Asset: Properties are represented as ERC-721 NFTs with on-chain metadata (location, size, value, condition).
- Actors:
Landlord(mints NFTs) andTenant(leases NFTs). - Mechanics:
- Dynamic rent calculation via a
viewfunction. - Fair exchange ensured by a 3-month rent deposit and dual confirmation.
- Landlord protection through deposit seizure on tenant default.
- End-of-lease options including termination and extension.
- Dynamic rent calculation via a
- 1. NFT Modeling: Implement ERC-721 with
Propertystruct andmintPropertyfunction. - 2. Dynamic Pricing: Implement the
computeMonthlyRentview function. - 3. Fair Exchange: Implement
applyAndDepositandconfirmLeasefunctions, including NFT escrow. - 4. Default Protection: Implement
claimDefaultfunction. - 5. End-of-Lease: Implement
payRent,terminateLease, andextendLeasefunctions.
.
├── contracts/
│ └── SmartLease.sol # Main contract (NFT + Leasing logic)
├── scripts/
│ ├── deploy.ts # Simple script that initiates the deployment
│ ├── ethers-lib.ts # Reusable helper with the core deployment
│ └── scenario.ts # Simulates E2E user flow for the demo
├── tests/
│ └── SmartLease_test.sol # Automated tests for contract functions
├── pdf/ # Assignment documents
└── ... # Other config and supporting files
contracts/SmartLease.sol: The single source of truth for all on-chain logic.scripts/deploy.ts: The main script to run for deployment. It's kept simple and calls the helper library.scripts/ethers-lib.ts: A helper library containing the reusabledeployfunction. This separates the complex deployment logic from the simple act of running the deployment.scripts/scenario.ts: The script to run for the final presentation. It will execute a full user story.tests/smartlease.test.js: Contains all unit tests. Essential for verifying contract correctness.
This project is designed to be developed, tested, and demonstrated entirely within the Remix IDE web interface.
- Clone the project into a Remix workspace using the "Clone" feature on the homepage with the GitHub URL.
- Work inside that workspace.
- Code: Edit
contracts/SmartLease.sol. - Compile:
- Go to the
Solidity Compilertab. - Select the correct compiler version (e.g.,
0.8.26). - Compile
SmartLease.sol.
- Go to the
- Test:
- Go to the
Solidity Unit Testingtab. - Select the
tests/directory. - Click "Run" to execute the tests in
SmartLease_test.sol.
- Go to the
- Deploy to a Testnet:
- In the
Deploy & Run Transactionstab, select an environment (e.g., "Injected Provider - MetaMask") connected to a testnet like Sepolia. - Deploy the
SmartLeasecontract. - Copy the deployed contract address.
- In the
- Run Demo Scenario:
- Alternatively, for a quick demo, run the scripts. Navigate to the
File Explorer. - Right-click
scripts/deploy.ts->Run. - Update
scripts/scenario.tswith the new address if needed. - Right-click
scripts/scenario.ts->Runto show the full simulation in the terminal.
- Alternatively, for a quick demo, run the scripts. Navigate to the