2020-02-04 15:57:33 +01:00
|
|
|
# Blockchain 101
|
2017-09-24 21:44:13 +02:00
|
|
|
|
2020-02-04 15:57:33 +01:00
|
|
|
Simple blockchain written in python
|
2017-09-24 21:44:13 +02:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
2020-02-04 15:57:33 +01:00
|
|
|
1. Make sure [Python 3.6+](https://www.python.org/downloads/) is installed.
|
|
|
|
2. Install [poetry](https://github.com/sdispater/poetry).
|
|
|
|
3. Install requirements
|
2017-10-02 11:48:10 +02:00
|
|
|
```
|
2020-02-04 15:57:33 +01:00
|
|
|
$ poetry install
|
2017-10-02 11:48:10 +02:00
|
|
|
```
|
|
|
|
|
2020-02-04 15:57:33 +01:00
|
|
|
4. Copy `.env.example` to `.env`
|
|
|
|
|
|
|
|
5. Start some nodes:
|
|
|
|
* `$ poetry run flask run -p 5000`
|
|
|
|
* `$ poetry run flask run -p 5001`
|
|
|
|
|
2017-10-03 20:01:36 +02:00
|
|
|
## Docker
|
|
|
|
|
2017-10-04 13:59:43 +02:00
|
|
|
Another option for running this blockchain program is to use Docker. Follow the instructions below to create a local Docker container:
|
|
|
|
|
2020-02-04 15:57:33 +01:00
|
|
|
1. Build the docker image
|
2017-10-03 20:01:36 +02:00
|
|
|
|
|
|
|
```
|
2020-02-04 15:57:33 +01:00
|
|
|
$ docker-compose build
|
2017-10-03 20:01:36 +02:00
|
|
|
```
|
|
|
|
|
2020-02-04 15:57:33 +01:00
|
|
|
2. Run the nodes
|
2017-10-03 20:01:36 +02:00
|
|
|
|
|
|
|
```
|
2020-02-04 15:57:33 +01:00
|
|
|
$ docker-compose up -d
|
2017-10-03 20:01:36 +02:00
|
|
|
```
|
|
|
|
|
2020-02-04 15:57:33 +01:00
|
|
|
4. To add more nodes, add a new service to the `docker-compose.yml` file
|
|
|
|
and adjust the port number.
|
2017-10-03 20:01:36 +02:00
|
|
|
|
2020-02-04 15:57:33 +01:00
|
|
|
```yaml
|
|
|
|
node2:
|
|
|
|
build: .
|
|
|
|
ports:
|
|
|
|
- 5002:80
|
2017-10-03 20:01:36 +02:00
|
|
|
```
|
2017-09-24 21:44:13 +02:00
|
|
|
|
2020-02-04 15:57:33 +01:00
|
|
|
## Credits
|
2017-10-02 11:48:10 +02:00
|
|
|
|
2020-02-04 15:57:33 +01:00
|
|
|
[dvf](github.com/dvf/) for the original blockchain code
|