# Bitcoin Mining Simulation ## Overview This project is a simple Python simulation of Bitcoin mining. It demonstrates the core concepts of blockchain mining, such as generating transactions, calculating hashes, and solving proof-of-work problems by finding a valid nonce. ## Features - Random transaction generation. - SHA-256 hashing of block data. - Proof-of-work implementation with adjustable difficulty. - Simulation of blockchain block creation. ## Requirements - Python 3.6+ ## Installation 1. Clone the repository or download the source code: ```bash git clone ``` ## Usage 1. Run the script: ```bash python main.py ``` 2. The program will generate random transactions, mine blocks, and display the resulting hashes. ### Example Output ``` Mining Block 1 with Transactions: 12345->67890->50; 54321->09876->30; 11111->22222->20 Block found! Nonce: 45678, Hash: 00000f9d6c24... New Hash: 00000f9d6c24... ``` ## Configuration The script contains configurable constants to adjust the mining simulation: - `MAX_NONCE`: Limits the number of nonce iterations for mining. Default is `1,000,000`. - `DIFFICULTY`: Specifies the number of leading zeros required in the hash. Default is `6`. To modify these values, edit the script directly: ```python MAX_NONCE = 1000000 # Set a higher or lower limit as needed DIFFICULTY = 6 # Adjust difficulty for faster or slower mining ``` ## Project Structure - `mining_simulation.py`: Main script containing all functionality for the simulation. ## How It Works 1. **Transaction Generation**: Random transactions are created with a sender, receiver, and amount of bitcoins. 2. **Hash Calculation**: Each block is hashed using SHA-256. 3. **Proof-of-Work**: The script iterates through possible nonce values to find a hash matching the difficulty. 4. **Blockchain Simulation**: Each block references the previous block's hash, forming a simple blockchain. ## Limitations - This is a simplified simulation and does not represent the full complexity of real-world Bitcoin mining. - The script is single-threaded and not optimized for performance. ## License This project is licensed under the MIT License. See the LICENSE file for details. ## Contributions Contributions are welcome! Feel free to fork the repository and submit pull requests. ## Contact For questions or suggestions, please reach out to [your email or GitHub profile].