This is blockchain-based application within a distributed peer-to-peer network.
Main purpose of this dapp is to allow users whithin the network to communicate each others by posting messages. These messages are processed as transactions and mined in order to add them to the blockchain.
The proof of work for this blockchain is based on the hash of each Block that might contain one or more transactions. Each transaction is defined by the next info:
- Author
- Content
- Timestamp
Each block is defined by the next:
- Index
- Transactions
- Timestamp
- Previous block (defined by its hash)
Algorithm consists in look for such a Nonce value that when calculating hash function for that block, result begin with "00".
The consensus for this blockchain is as simple as just select the larger chain as the valid chain
It's possible to run this Dapp (Descentralized Application) by two ways
This tutorial is assuming you have python installed and running on a Linux-based OS
If you go by this way, I suggest you to use virtual environment
- Clone this repo
git clone https://github.com/ManuGS2/Blockchain.git
- Go to the folder
cd Blockchain
- Install the dependencies
pip install -r server/requirements.txt
pip install -r front/requirements.txt
- Run the node server for connecting to blockchain network with the next commands
export FLASK_APP=server/blockchain_api.py
flask run --port 8000
- Run the web application with the next commands
export FLASK_APP=front/views.py
flask run --port 5000
- If you want to run more nodes, just follow the samen in step 4 but changing the port
export FLASK_APP=server/blockchain_api.py
flask run --port 8001
Your web application will be running on http://127.0.0.1:5000/
NOTE: for each instance of the web app or node server it's necessary to open new console window
If you go by this way, you need to have docker installed in your machine as well as docker-compose in onder to run this Dapp in containers.
If you don't have docker neither docker-compose installed follow the instructions from official page.
Once you have docker compose installed follow the next steps
- Clone this repo
git clone https://github.com/ManuGS2/Blockchain.git
- Go to the folder
cd Blockchain
- Build, crate and run the containers
docker-compose up --build
This last command will run the services defined in docker-compose.yml file. You can modify it in order to create more nodes or instances
By default this will create 1 web app instances, 2 nodes and 1 redis instance.
Your web application will be running on http://127.0.0.1:5000/