Skip to content

A simple blockchain implementation in Python with basic features like transaction handling, proof of work, and mining rewards. Ideal for beginners looking to understand blockchain concepts.

License

Notifications You must be signed in to change notification settings

vaishaliisingh/Blockchain-fundamentals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Blockchain-fundamentals

Basic Blockchain Implementation: This project is a simple blockchain implementation in Python. It demonstrates how a basic blockchain works, including block creation, proof of work, and transaction handling. The project also includes a mining reward feature for miners who successfully add new blocks to the blockchain.

Features

  • Block Creation: New blocks can be created and added to the blockchain. Each block contains a list of transactions, a proof of work, a timestamp, and a hash linking to the previous block.
  • Proof of Work: A simple proof of work algorithm is implemented to secure the blockchain. This helps ensure that the blockchain is tamper-proof.
  • Transaction Handling: Transactions between different participants are recorded on the blockchain.
  • Mining Reward: Miners are rewarded with a fixed amount of cryptocurrency for successfully mining a block.

Code Structure

  • Blockchain Class: The main class that handles the creation of blocks, proof of work, transaction management, and blockchain validation.
  • Proof of Work Method: The method that implements the proof of work algorithm, ensuring the security of the blockchain.
  • Transaction Method: A method to add new transactions to the blockchain.
  • Mining Reward: A reward mechanism that grants miners a fixed amount of cryptocurrency when they successfully mine a block.

How to Run

  1. Clone the Repository:
    git clone https://github.com/yourusername/blockchain-project.git
    cd blockchain-project
    python blockchain.py
  2. Install Dependencies: This project doesn't require any external dependencies, as it relies on core Python libraries.
  3. Run the Code: You can run the blockchain code using Python:
        python blockchain.py
  4. Add Transactions: You can manually add transactions to the blockchain by modifying the new_transaction method call in the code.
  5. Mine a New Block: After adding transactions, mine a new block using the proof_of_work method.

Example Output

When you run the code, you will see output similar to the following:

New block created: { 'index': 2, 'timestamp': 1725686992.3320613, 'transactions': [ {'sender': 'Alice', 'recipient': 'Bob', 'amount': 50}, {'sender': '0', 'recipient': 'Miner1', 'amount': 1} ], 'proof': 35293, 'previous_hash': '6eeb66a1882d22b4b6f33ec057d241af2f46ba6d51837d2b72ed94e4fcad7aed' }

Future Scope

Here are some additional features that can be added to this blockchain implementation:

  1. Blockchain Validation (Valid Chain): Implement a method to validate the entire blockchain and ensure it has not been tampered with.
  2. Consensus Algorithm: Implement a consensus algorithm to ensure all nodes in a network agree on the same blockchain.
  3. Merkle Trees: Improve transaction handling by implementing Merkle trees, which would help efficiently verify the contents of a block.
  4. Networking: Extend this project by enabling communication between multiple nodes (computers), allowing them to share and synchronize their blockchain.

Contributing

Feel free to submit issues, fork the repository, and make pull requests. Contributions are welcome to enhance this beginner-level blockchain implementation.

License

This project is licensed under the MIT License

Acknowledgments

  1. This project is inspired by various blockchain tutorials and projects available online.
  2. pecial thanks to the community for their valuable insights and feedback.

About

A simple blockchain implementation in Python with basic features like transaction handling, proof of work, and mining rewards. Ideal for beginners looking to understand blockchain concepts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages