Smart Contract Risk Analysis Tool

Smart Contract Risk Analyzer

Simulated vulnerability scanning for Solidity code.

Scan results will appear here

Identified Vulnerabilities

SeverityVulnerabilityDescription

Analyzed Code


    

${vuln.description}

`).join(''); } else { vulnerabilitiesList.innerHTML = `
No major vulnerabilities identified.
`; } outputPlaceholder.classList.add('hidden'); resultsDashboard.classList.remove('hidden'); } async function handlePdfDownload() { document.getElementById('pdf-header').innerHTML = `

Smart Contract Security Report

Generated: ${new Date().toLocaleString()}

`; document.getElementById('pdf-summary').innerHTML = `

Overall Risk: ${analysisData.overallRisk}

Summary: ${analysisData.summary}

`; document.querySelector('#pdf-vulnerabilities-table tbody').innerHTML = analysisData.vulnerabilities.map(v => ` ${v.severity}${v.name}${v.description} `).join(''); document.getElementById('pdf-code-block').textContent = analysisData.contractCode; const contentToPrint = document.getElementById('pdf-output'); contentToPrint.style.display = 'block'; try { const canvas = await html2canvas(contentToPrint, { scale: 2 }); const { jsPDF } = window.jspdf; const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = (canvas.height * pdfWidth) / canvas.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight); pdf.save(`Smart-Contract-Report.pdf`); } catch (err) { console.error("Error generating PDF:", err); alert("Could not generate PDF."); } finally { contentToPrint.style.display = 'none'; } } // --- EVENT LISTENERS --- analyzeBtn.addEventListener('click', handleAnalysis); downloadPdfBtn.addEventListener('click', handlePdfDownload); // --- INITIALIZATION --- lucide.createIcons(); // Sample code contractCodeInput.value = `// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract EtherStore { mapping(address => uint256) public balances; function deposit() public payable { balances[msg.sender] += msg.value; } function withdraw() public { uint256 bal = balances[msg.sender]; require(bal > 0); (bool success, ) = msg.sender.call{value: bal}(""); require(success, "Failed to send Ether"); balances[msg.sender] = 0; } }`; });
Scroll to Top