Smart Contract-Based Real Estate Transactions Tracker

Smart Contract-Based Real Estate Transactions Tracker

(Simulation Tool - Does not interact with actual blockchains)

Current Transactions

No transactions added yet. Go to "Add New Transaction" tab.

Add New Real Estate Transaction

Seller Wallet (Sim): ${tx.sellerWallet || 'N/A'}

Buyer Wallet (Sim): ${tx.buyerWallet || 'N/A'}

Smart Contract Address (Sim): ${tx.contractAddress || 'N/A'}

Initiated: ${formatDate(tx.initiatedAt)}

Last Updated: ${formatDate(tx.lastUpdatedAt)}

Event Log:
`; if (tx.eventLog.length > 0) { tx.eventLog.slice().reverse().forEach(log => { // Show newest first bodyContent += `
${formatDate(log.timestamp)}: ${log.description}
`; }); } else { bodyContent += `

No events logged.

`; } bodyContent += `
`; modalBodyElem.innerHTML = bodyContent; updateStatusSelectElem.value = tx.status; // Pre-fill current status document.getElementById('newEventLog').value = ''; // Clear previous event log input transactionModalElem.style.display = "block"; } function closeTransactionModal() { if (transactionModalElem) transactionModalElem.style.display = "none"; } function saveTransactionUpdate() { const transactionId = modalTransactionIdElem.value; const newStatus = updateStatusSelectElem.value; const newEventDescription = document.getElementById('newEventLog').value.trim(); const txIndex = transactionsData.findIndex(t => t.id === transactionId); if (txIndex === -1) { alert("Transaction not found!"); return; } let updated = false; if (transactionsData[txIndex].status !== newStatus) { transactionsData[txIndex].status = newStatus; transactionsData[txIndex].eventLog.push({ timestamp: new Date(), description: `Status changed to: ${newStatus}` }); updated = true; } if (newEventDescription) { transactionsData[txIndex].eventLog.push({ timestamp: new Date(), description: newEventDescription }); updated = true; } if (updated) { transactionsData[txIndex].lastUpdatedAt = new Date(); renderTransactionsTable(); alert("Transaction updated successfully!"); } else { alert("No changes made."); } closeTransactionModal(); } function generatePdf() { if (transactionsData.length === 0) { alert("No transactions to download."); return; } const pdf = new jsPDF(); const today = new Date().toLocaleDateString(); pdf.setFontSize(18); pdf.setTextColor(59, 130, 246); // Tailwind blue-600 pdf.text("Real Estate Transactions Report (Simulated)", 105, 20, null, null, "center"); pdf.setFontSize(10); pdf.setTextColor(100); pdf.text(`Generated on: ${today}`, 105, 28, null, null, "center"); const tableColumn = ["ID", "Property", "Price ($)", "Status", "Contract Addr.", "Last Updated"]; const tableRows = []; transactionsData.forEach(tx => { const txData = [ tx.id.toString().slice(-8), // Shorter ID for PDF tx.propertyAddress, tx.price.toFixed(2), tx.status, tx.contractAddress || "N/A", formatDate(tx.lastUpdatedAt) ]; tableRows.push(txData); }); pdf.autoTable({ head: [tableColumn], body: tableRows, startY: 35, theme: 'grid', headStyles: { fillColor: [59, 130, 246] }, // blue-600 styles: { fontSize: 8, cellPadding: 2 }, margin: { left: 14, right: 14 } }); pdf.save("Real_Estate_Transactions_Report.pdf"); } // Event Listeners & Initialization document.addEventListener('DOMContentLoaded', () => { transactionsTableContainerElem = document.getElementById('transactionsTableContainer'); addTransactionFormElem = document.getElementById('addTransactionForm'); downloadPdfButtonElem = document.getElementById('downloadPdfButton'); transactionModalElem = document.getElementById('transactionModal'); modalTitleElem = document.getElementById('modalTitle'); modalBodyElem = document.getElementById('modalBody'); modalTransactionIdElem = document.getElementById('modalTransactionId'); updateStatusSelectElem = document.getElementById('updateStatusSelect'); newEventLogElem = document.getElementById('newEventLog'); if (!addTransactionFormElem || !downloadPdfButtonElem || !transactionModalElem) { console.error("Critical DOM elements are missing. Tool may not function correctly."); return; } addTransactionFormElem.addEventListener('submit', handleAddTransaction); downloadPdfButtonElem.addEventListener('click', generatePdf); renderTransactionsTable(); // Initial render changeTab(null, 'tabDashboard'); // Initialize first tab }); // Close modal if user clicks outside of it window.onclick = function(event) { if (event.target == transactionModalElem) { closeTransactionModal(); } }
Scroll to Top