Public
Code
HTTP
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import React, { useState, useEffect } from "https://esm.sh/react@18.2.0";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
// Cryptocurrency Mining Simulator
function CryptoMiningApp() {
const [miners, setMiners] = useState([
{ name: "Bitcoin", hashRate: 0, power: 0, isActive: false },
{ name: "Ethereum", hashRate: 0, power: 0, isActive: false },
{ name: "Bnb", hashRate: 0, power: 0, isActive: false }
]);
const [totalEarnings, setTotalEarnings] = useState(0);
const [energyCost, setEnergyCost] = useState(0);
const toggleMiner = (index: number) => {
const updatedMiners = [...miners];
updatedMiners[index].isActive = !updatedMiners[index].isActive;
if (updatedMiners[index].isActive) {
// Simulate realistic mining parameters
updatedMiners[index].hashRate = Math.random() * 500 + 50; // 50-550 MH/s
updatedMiners[index].power = Math.random() * 800 + 200; // 200-1000 watts
} else {
updatedMiners[index].hashRate = 0;
updatedMiners[index].power = 0;
}
setMiners(updatedMiners);
};
useEffect(() => {
const interval = setInterval(() => {
const activeMiners = miners.filter(miner => miner.isActive);
const earnings = activeMiners.reduce((total, miner) =>
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
sagar445-realminingapps.web.val.run
Updated: January 11, 2025