Fabulosa recipe

đź§Ş DIY Fabuloso-Style All-Purpose Cleaner

Ingredients:

  • 2 cups water (distilled preferred)
  • 1 cup white vinegar (natural degreaser and disinfectant)
  • 1/2 cup rubbing alcohol (optional – cuts grease, disinfects, helps it dry faster)
  • 1 teaspoon liquid dish soap (like Dawn)
  • 10–20 drops essential oil (lavender for classic Fabuloso smell, or citrus/eucalyptus)
  • (Optional) A few drops of food coloring to match the Fabuloso look

UI.js

let chain = new Blockchain();
let wallet = loadWallet();

async function createWallet() {
const keys = await generateWallet();
saveWallet(keys.publicKey, keys.privateKey);
wallet = loadWallet();
updateUI();
}

async function updateUI() {
document.getElementById(“address”).value = wallet.address || “”; document.getElementById(“privKey”).value = wallet.privateKey || “”;
document.getElementById(“balance”).innerText = “Balance: ” + await chain.getBalance(wallet.address || “N/A”) + ” RAY”;
document.getElementById(“chainView”).innerText = JSON.stringify(chain.chain, null, 2); }

async function sendTx() {
const to = document.getElementById(“to”).value;
const amount = parseFloat(document.getElementById(“amount”).value); if (!to || !amount || amount <= 0) return alert(“Invalid input”);

const tx = { from: wallet.address, to, amount };
await chain.addTransaction(tx);
updateUI();
}

async function mineBlock() {
document.getElementById(“mineStatus”).innerText = “Mining…”; const block = await chain.mine(wallet.address);
document.getElementById(“mineStatus”).innerText = “Mined block #” + block.index + ” âś…”; updateUI();
}

updateUI();

Blockchain.js

class Block {
constructor(index, previousHash, timestamp, transactions, nonce, hash) { this.index = index;
this.previousHash = previousHash;
this.timestamp = timestamp;
this.transactions = transactions;
this.nonce = nonce;
this.hash = hash;
}
}

class Blockchain {
constructor() {
this.chain = [];
this.mempool = [];
this.load();
}

getLastBlock() {
return this.chain[this.chain.length – 1];
}

async addTransaction(tx) {
this.mempool.push(tx);
this.save();
}

async mine(publicKey) {
const lastBlock = this.getLastBlock() || { index: 0, hash: “0” }; const index = lastBlock.index + 1;
const timestamp = Date.now();
const rewardTx = { from: “network”, to: publicKey, amount: 10 }; const transactions = [rewardTx, …this.mempool];
let nonce = 0;
let hash = “”;

while (true) {
const data = index + lastBlock.hash + timestamp + JSON.stringify(transactions) + nonce; hash = await sha256(data);
if (hash.startsWith(“0000”)) break;
nonce++;
}

const block = new Block(index, lastBlock.hash, timestamp, transactions, nonce, hash); this.chain.push(block);
this.mempool = [];
this.save();
return block;
}

async getBalance(address) {
let balance = 0;
for (const block of this.chain) {
for (const tx of block.transactions) {
if (tx.to === address) balance += tx.amount;
if (tx.from === address) balance -= tx.amount;
}
}
return balance;
}

save() {
localStorage.setItem(“raycoin_chain”, JSON.stringify(this.chain)); localStorage.setItem(“raycoin_mempool”, JSON.stringify(this.mempool)); }

load() {
this.chain = JSON.parse(localStorage.getItem(“raycoin_chain”) || “[]”); this.mempool = JSON.parse(localStorage.getItem(“raycoin_mempool”) || “[]”); }
}

async function sha256(str) {
const buf = await crypto.subtle.digest(“SHA-256”, new TextEncoder().encode(str));
return […new Uint8Array(buf)].map(x => x.toString(16).padStart(2, “0”)).join(“”); }

Wallet.js

// Basic ECC wallet using crypto.subtle (in-browser)

async function generateWallet() {
const keyPair = await crypto.subtle.generateKey(
{ name: “ECDSA”, namedCurve: “P-256” },
true,
[“sign”, “verify”]
);

const privKey = await crypto.subtle.exportKey(“jwk”, keyPair.privateKey); const pubKey = await crypto.subtle.exportKey(“jwk”, keyPair.publicKey);

return {
privateKey: JSON.stringify(privKey),
publicKey: JSON.stringify(pubKey),
};
}

Solar NowNow