Home

Cryptocurrency & Blockchain Basics: A Live Demo

Explore the fundamental concepts behind cryptocurrencies and blockchain technology, right in your browser! Your chain is stored locally.

Current Balances

Max Supply: | Coins in Circulation:

Current Block Reward:

Add Transactions to Next Block

Transactions Waiting for Next Block:

No transactions waiting to be mined. Add new transactions above!

(Max 3 for demo speed)

Your Blockchain

Welcome to the Simple Cryptocurrency & Blockchain Live Demo!

This tool helps you understand how a blockchain works by letting you create and manage your own chain of blocks. It also demonstrates how a digital currency can function on top of this technology. All data is processed and stored locally in your browser.

Note: For demo purposes, the total coin supply is fixed at 1000. New coins are only created as block rewards, which halve every 5 blocks. Alice and Bob start with 0 balance.

Understanding This Cryptocurrency & Blockchain Demo

What is a Blockchain?

Imagine a digital ledger, like a very secure notebook, where information is recorded in "blocks." Each block is linked to the previous one, forming a "chain." Once a block is added, it's very difficult to change, making the record highly secure and transparent. Think of it like a never-ending, unchangeable history book that everyone can see and verify.

What is a Cryptocurrency?

A cryptocurrency is a digital or virtual currency that uses cryptography for security. It is typically decentralized, meaning it is not subject to government or financial institution control. This demo illustrates how a basic cryptocurrency can operate on a blockchain, allowing for digital value transfer and tracking of balances without a central authority.

The Building Blocks:

  • Block: This is like a page in our digital history book. Each page (block) contains several important pieces of information:
    • Index: This is simply the block's number, showing its position in the chain (e.g., Block #0 is the very first page, Block #1 is the second, and so on).
    • Timestamp: This records the exact date and time when the block was created and added to the chain. It's like a date stamp on a document.
    • Data (Transactions): This is the actual information stored in the block. In this demo, the data is a list of "transactions" – records of value being moved between different users (like Alice, Bob, or the Miner).
    • Previous Hash: This is a unique digital fingerprint (like a barcode) of the *block that came just before it*. This is incredibly important because it's how blocks are securely linked together, forming the "chain." If you change a previous block, its fingerprint changes, and this link breaks!
    • Hash (Digital Fingerprint): This is the unique digital fingerprint for *this specific block*. It's a special code generated from *all* the information inside this block (its index, timestamp, data, and even the "nonce"). Even a tiny change to any part of the block's data will completely change its hash, making it easy to spot if someone tries to tamper with it.
    • Nonce: This stands for "Number Used Once." It's a random number that miners (your browser, in this demo) keep changing until they find a special hash that meets a certain condition (like starting with a specific number of zeros). It's a key part of the "mining" process.
  • Transaction: A record of an exchange of value. In our demo, it's simply "Sender sent Amount to Receiver." These transactions are grouped together and added to a block.
  • Wallet/Balance: A digital account that holds a certain amount of "coins" or value. Our demo tracks simple balances for "Miner," "Alice," and "Bob."

How Blocks are Added (Mining & Proof of Work):

To add a new page (block) to our secure history book (blockchain), we go through a process called "mining." This isn't like digging for gold; it's a digital puzzle-solving task. Your computer (or "miner") tries to find a special "Nonce" (that random number we talked about). It keeps guessing different nonces until the block's unique digital fingerprint (its "Hash") starts with a certain number of zeros. This "number of zeros" is the "difficulty" you can set.

This process of finding the right nonce that results in a valid hash is called "Proof of Work." It requires your computer to do some computational effort, which makes it hard for anyone to quickly create fake blocks. When you click "Mine & Add Block," your browser is performing this "Proof of Work" to secure your new block.

As a reward for successfully mining a block, the "Miner" account receives a small amount of coins (a "block reward"). This incentivizes people to participate in securing the blockchain and introduces new currency into the system, similar to how new Bitcoin is created.

Why is it Secure? (Immutability)

The blockchain gets its security from something called "immutability," which means "unchangeable." Because each block's unique digital fingerprint (its "Hash") depends on *all* its own content AND the fingerprint of the *previous* block, changing any information in an old block would immediately change its hash. This would then break the link to the next block in the chain, and all blocks that came after it would become invalid.

Think of it: if you change a page in the middle of our history book, its barcode changes. Then, the next page, which references the old barcode, suddenly has a wrong reference, and its barcode changes too, and so on. This chain reaction makes any tampering instantly visible and very difficult to hide, as you would have to re-do the "Proof of Work" (re-mine) for every single block after the one you changed!

In this demo, if you try to manually change a block's data (using the browser's developer console with the `tamperBlock()` function), you'll see that block and all following blocks turn red. This visually shows how the chain is broken and the tampering is detected. You can then use the "Re-mine Block" button on an invalid block to see the effort required to fix the chain from that point forward.

Import/Export Feature:

This demo stores your blockchain locally within your web browser. This means your data stays on your device and isn't sent anywhere else. The "Export Blockchain" button allows you to save your entire current blockchain as a JSON file to your computer. This is like making a backup copy of your digital history book. The "Import Blockchain" button lets you load a previously saved blockchain from a JSON file, so you can continue your work or restore your chain even if your browser's data is cleared.

How to Use This Demo: A Step-by-Step Guide

  1. Observe Initial State: When you first open the app, you'll see the "Current Balances" section. The "Max Supply" and "Coins in Circulation" will be displayed. Note that the "Miner" account will start with 100 coins, as the Genesis Block (Block #0) is automatically mined upon startup, granting the initial block reward. Alice and Bob will start with 0 balance.
  2. Add Transactions:
    • Use the "From," "To," and "Amount" dropdowns/input in the "Add Transactions to Next Block" section.
    • Select a sender (e.g., Miner, Alice, Bob), a receiver, and an amount.
    • Click the "Add Transaction" button. The transaction will appear in the "Transactions Waiting for Next Block" list. You can add multiple transactions.
    • Note: You cannot send more coins than you currently possess.
  3. Adjust Mining Difficulty:
    • Use the "Mining Difficulty (leading zeros):" dropdown.
    • Choose a difficulty (1, 2, or 3). Higher numbers mean more leading zeros are required in the hash, making mining harder and slower (but more secure). For a quick demo, 1 or 2 is recommended.
  4. Mine a New Block:
    • Once you have pending transactions (or if you just want to mine an empty block for the reward), click the "Mine & Add Block" button.
    • The "Mining..." progress will show the nonce increasing as your browser performs "Proof of Work."
    • Upon successful mining, the new block will be added to "Your Blockchain," and the balances will update. The "Miner" will receive the current block reward.
  5. Observe Halving Events: Pay attention to the "Current Block Reward" in the "Current Balances" section. It will automatically halve every 5 blocks, demonstrating the fixed supply mechanism. Once the "Coins in Circulation" reaches the "Max Supply," the reward will become 0.
  6. Explore Immutability (Tampering):
    • Open your browser's developer console (usually F12 or right-click -> Inspect -> Console tab).
    • Type `tamperBlock(blockIndex, 'Your new data here');` (e.g., `tamperBlock(1, 'I stole all the coins!');`).
    • Observe how the tampered block and all subsequent blocks turn red, indicating the chain is broken.
    • To fix it, click the "Re-mine Block" button on the first red (invalid) block. This demonstrates the effort required to alter past data.
  7. Save and Load Your Chain:
    • Click "Export Blockchain" to save your current chain and balances as a JSON file to your computer.
    • Click "Import Blockchain" and select a previously exported JSON file to load a saved chain. This is useful for continuing your demo or restoring a state.
  8. Toggle Theme: Use the sun/moon icon button in the top right corner to switch between light and dark themes.

Related tools List

Discover more free online Productivity & Financial Tools!. Explore our collection of Productivity & Financial Tools.