Spaces:
Running
Running
Download index.html from Logan897324/dapp: direct link, hf CLI and curl.
- Browser
- Download file 7.89 kB
-
https://huggingface.co/spaces/Logan897324/dapp/resolve/main/index.html
- Command line
-
hf download hf://spaces/Logan897324/dapp/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Logan897324/dapp/resolve/main/index.html
7.89 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>Web3 Wallet App</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/ethers@5.7.2/dist/ethers.umd.min.js"></script> | |
| <script src="https://unpkg.com/web3modal"></script> | |
| <script src="https://unpkg.com/@walletconnect/web3-provider"></script> | |
| <script src="https://unpkg.com/evm-chains"></script> | |
| </head> | |
| <body class="bg-gray-100 dark:bg-gray-900 text-gray-900 dark:text-gray-100 min-h-screen"> | |
| <!-- Header with menu and theme switch --> | |
| <header class="flex items-center justify-between p-4 shadow-md bg-white dark:bg-gray-800"> | |
| <h1 class="text-xl font-bold">Web3 Wallet</h1> | |
| <div class="flex items-center gap-4"> | |
| <button id="themeToggle" class="px-2 py-1 rounded bg-gray-200 dark:bg-gray-700">🌙</button> | |
| <button id="menuBtn" class="p-2 rounded bg-gray-200 dark:bg-gray-700">☰</button> | |
| </div> | |
| </header> | |
| <!-- Side Menu --> | |
| <nav id="sideMenu" class="fixed top-0 right-0 w-64 h-full bg-white dark:bg-gray-800 shadow-lg transform translate-x-full transition-transform duration-300 z-50"> | |
| <div class="flex flex-col p-4 space-y-4"> | |
| <button data-page="dashboard" class="nav-link text-left">Dashboard</button> | |
| <button data-page="trading" class="nav-link text-left">Trading</button> | |
| <button data-page="deposit" class="nav-link text-left">Deposit</button> | |
| <button data-page="withdraw" class="nav-link text-left">Withdraw</button> | |
| <button data-page="transactions" class="nav-link text-left">Transactions</button> | |
| </div> | |
| </nav> | |
| <!-- Pages --> | |
| <main class="p-4"> | |
| <!-- Dashboard --> | |
| <section id="dashboard" class="page"> | |
| <h2 class="text-2xl font-bold mb-4">Dashboard</h2> | |
| <button id="connectWallet" class="px-4 py-2 bg-blue-500 text-white rounded">Connect Wallet</button> | |
| <div id="walletInfo" class="mt-4"></div> | |
| </section> | |
| <!-- Trading --> | |
| <section id="trading" class="page hidden"> | |
| <h2 class="text-2xl font-bold mb-4">Trading</h2> | |
| <div id="tradingview" style="height:500px;"></div> | |
| </section> | |
| <!-- Deposit --> | |
| <section id="deposit" class="page hidden"> | |
| <h2 class="text-2xl font-bold mb-4">Deposit</h2> | |
| <p>Your wallet address:</p> | |
| <p id="depositAddress" class="font-mono break-words"></p> | |
| <canvas id="qrCode" class="mt-4"></canvas> | |
| </section> | |
| <!-- Withdraw --> | |
| <section id="withdraw" class="page hidden"> | |
| <h2 class="text-2xl font-bold mb-4">Withdraw</h2> | |
| <input id="withdrawTo" type="text" placeholder="Recipient Address" class="w-full p-2 border rounded mb-2" /> | |
| <input id="withdrawAmount" type="number" placeholder="Amount (ETH)" class="w-full p-2 border rounded mb-2" /> | |
| <button id="withdrawBtn" class="px-4 py-2 bg-red-500 text-white rounded">Send</button> | |
| <p id="withdrawStatus" class="mt-2"></p> | |
| </section> | |
| <!-- Transactions --> | |
| <section id="transactions" class="page hidden"> | |
| <h2 class="text-2xl font-bold mb-4">Transactions</h2> | |
| <ul id="txList" class="space-y-2"></ul> | |
| </section> | |
| </main> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/qrious/4.0.2/qrious.min.js"></script> | |
| <script type="text/javascript"> | |
| // State | |
| let provider, signer, selectedAccount; | |
| // Theme Toggle | |
| document.getElementById('themeToggle').addEventListener('click', () => { | |
| document.documentElement.classList.toggle('dark'); | |
| }); | |
| // Menu Toggle | |
| const menuBtn = document.getElementById('menuBtn'); | |
| const sideMenu = document.getElementById('sideMenu'); | |
| menuBtn.addEventListener('click', () => { | |
| sideMenu.classList.toggle('translate-x-full'); | |
| }); | |
| // Navigation | |
| document.querySelectorAll('.nav-link').forEach(btn => { | |
| btn.addEventListener('click', () => { | |
| const target = btn.getAttribute('data-page'); | |
| document.querySelectorAll('.page').forEach(p => p.classList.add('hidden')); | |
| document.getElementById(target).classList.remove('hidden'); | |
| sideMenu.classList.add('translate-x-full'); | |
| }); | |
| }); | |
| // Wallet Connect (Web3Modal) | |
| const providerOptions = { | |
| walletconnect: { | |
| package: window.WalletConnectProvider.default, | |
| options: { | |
| infuraId: "https://mainnet.infura.io/v3/" | |
| } | |
| } | |
| }; | |
| const web3Modal = new window.Web3Modal.default({ | |
| cacheProvider: false, | |
| providerOptions | |
| }); | |
| document.getElementById('connectWallet').addEventListener('click', async () => { | |
| const instance = await web3Modal.connect(); | |
| provider = new ethers.providers.Web3Provider(instance); | |
| signer = provider.getSigner(); | |
| selectedAccount = await signer.getAddress(); | |
| document.getElementById('walletInfo').innerText = `Connected: ${selectedAccount}`; | |
| document.getElementById('depositAddress').innerText = selectedAccount; | |
| // QR Code | |
| new QRious({ element: document.getElementById('qrCode'), value: selectedAccount, size: 200 }); | |
| }); | |
| // Withdraw | |
| document.getElementById('withdrawBtn').addEventListener('click', async () => { | |
| const to = document.getElementById('withdrawTo').value; | |
| const amount = document.getElementById('withdrawAmount').value; | |
| try { | |
| const tx = await signer.sendTransaction({ to, value: ethers.utils.parseEther(amount) }); | |
| document.getElementById('withdrawStatus').innerText = `Sent! Tx hash: ${tx.hash}`; | |
| } catch (e) { | |
| document.getElementById('withdrawStatus').innerText = `Error: ${e.message}`; | |
| } | |
| }); | |
| // Transactions (basic example: fetch last 5 tx from Etherscan) | |
| async function loadTransactions() { | |
| if (!selectedAccount) return; | |
| const res = await fetch(`https://api.etherscan.io/api?module=account&action=txlist&address=${selectedAccount}&sort=desc`); | |
| const data = await res.json(); | |
| const txs = data.result.slice(0,5); | |
| const list = document.getElementById('txList'); | |
| list.innerHTML = ''; | |
| txs.forEach(tx => { | |
| const li = document.createElement('li'); | |
| li.textContent = `${tx.from === selectedAccount ? 'Sent' : 'Received'} ${ethers.utils.formatEther(tx.value)} ETH - Hash: ${tx.hash}`; | |
| list.appendChild(li); | |
| }); | |
| } | |
| document.querySelector('[data-page="transactions"]').addEventListener('click', loadTransactions); | |
| // TradingView Embed | |
| function loadTradingView() { | |
| document.getElementById('tradingview').innerHTML = ''; | |
| new TradingView.widget({ | |
| container_id: "tradingview", | |
| autosize: true, | |
| symbol: "ETHUSD", | |
| interval: "D", | |
| theme: document.documentElement.classList.contains('dark') ? "dark" : "light", | |
| style: "1", | |
| locale: "en", | |
| enable_publishing: false, | |
| hide_top_toolbar: false, | |
| hide_legend: false, | |
| }); | |
| } | |
| document.querySelector('[data-page="trading"]').addEventListener('click', loadTradingView); | |
| </script> | |
| <script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Logan897324/dapp" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> | |