Skip to content

A basic blockchain implementation in C++ that allows users to create a blockchain, add blocks with transactions, view the entire chain, and validate its integrity.

License

Notifications You must be signed in to change notification settings

ajaykumargdr/basic-blockchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Blockchain Implementation

This project is a simple implementation of a blockchain in C++. It demonstrates the basic concepts of a blockchain, including blocks, transactions, and the cryptographic hashing mechanism that ensures the integrity and immutability of the blockchain.

Table of Contents

Introduction

A blockchain is a decentralized and immutable digital ledger that records transactions across multiple computers. It ensures transparency, security, and trust in financial transactions by linking blocks of data together in a sequential and cryptographically secure manner.

Features

  • Create a new blockchain
  • Add blocks with transactions to the blockchain
  • Print the entire blockchain
  • Validate the integrity of the blockchain

Installation

Prerequisites

  • C++ compiler (e.g., GCC, Clang, or MSVC)

Windows

  1. Download and install MinGW from the official website: MinGW.
  2. After installation, add the MinGW bin directory to your system's PATH environment variable.

macOS

macOS comes with a pre-installed GCC compiler. However, you can also install the latest version of GCC or Clang from Homebrew:

  1. Install Homebrew by following the instructions on the official website.

  2. Once Homebrew is installed, run the following command to install GCC:

    brew install gcc

    Or, install Clang with:

    brew install llvm

Linux

Most Linux distributions come with GCC pre-installed. If not, you can install it using your distribution's package manager. read more.

  • On Debian-based distributions (e.g., Ubuntu):

    sudo apt-get install build-essential

Usage

  1. Clone the repository:

    git clone https://github.com/ajaykumargdr/basic-blockchain.git
    
  2. Navigate to the blockchain folder:

    cd basic-blockchain/blockchain
    
  3. Compile the source code using the appropriate compiler command for your operating system:

    • On Windows (MinGW):

      g++ -std=c++11 -o main main.cpp block.cpp blockchain.cpp transaction.cpp
    • On macOS or Linux (GCC):

      g++ -std=c++11 -o main main.cpp block.cpp blockchain.cpp transaction.cpp
    • On macOS or Linux (Clang):

      clang++ -std=c++11 -o main main.cpp block.cpp blockchain.cpp transaction.cpp
  4. Run the compiled executable:

    ./main

    This will create a new blockchain, add some sample blocks with transactions, print the entire blockchain, and validate its integrity.

Contributing

Contributions to this project are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

About

A basic blockchain implementation in C++ that allows users to create a blockchain, add blocks with transactions, view the entire chain, and validate its integrity.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages