A simple simulator that gamifies the core mechanics of the Bitcoin protocol, including the mempool, transaction selection, and proof-of-work mining.
This application demonstrates how Bitcoin miners select transactions from the mempool and solve mathematical puzzles to append new blocks to the blockchain. Players act as miners who must adhere to the protocol's rules to successfully mine a block and update the global ledger.
- Transaction Validity: A transaction is only valid if the sender has sufficient balance to cover both the transaction amount and the associated miner fee.
- Mempool: Unconfirmed transactions broadcasted to the network are held in the mempool.
- Transaction Selection (Fee Market): Miners are economically incentivized to maximize their profit. Therefore, you must select transactions with the highest miner fees. In the event of a tie in fees, prioritize older transactions (represented by lower transaction IDs or earlier appearance).
- Block Size Limit: In this simulation, each block can contain exactly 3 transactions, mirroring Bitcoin's block weight limit in a simplified manner.
- Proof of Work (Mining): To mine a block, a miner must find a "Nonce" (Number used once) that, when combined with the block's data, satisfies the network's difficulty target.
- Immutable Ledger: Once a block is successfully mined, the transactions are processed, and the balance sheet is updated. Previous blocks form a chain that cannot be altered.
- Review the Mempool: Observe the unconfirmed transactions available in the mempool. Some transactions might be invalid or attempt to spend more than the available balance.
- Select Transactions: Choose exactly 3 valid transactions. You must strictly follow the fee priority rule, picking the ones with the highest fees.
- Check Balances: Ensure that the senders have enough balance to cover the total amount and fees for all your selected transactions. The system will reject invalid selections.
- Calculate Block Value: The application computes a block value based on the selected transactions' amounts, fees, and the mathematical values of the sender and receiver names:
Sender Names Number + Receiver Names Number + Amount of BTCs + Fees = Block Value - Find the Nonce: Guess a positive number for the Nonce. Your goal is to satisfy the equation:
Previous Target + Nonce + Block Value = Current Target - Mine the Block: Submit your Nonce. If the equation holds true, the block is successfully mined, balances are updated, and the network advances to the next block with a new target. If incorrect, try another Nonce.
By https://bitpolito-mining-game.vercel.app
Or for running this simulator on your local machine:
- Navigate to the project directory.
- Install the dependencies: npm install
- Start the development server: npm run dev
- Open the provided localhost URL in your web browser.