seifip / tiny-blockchain

A tiny Python blockchain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tiny Blockchain

This is a port of snakecoin to use Docker and Python 3. All credit to @aunyks and https://github.com/zacanger who wrote the originals.

The idea is a toy Python blockchain to be used as a playground for experimentation.

This version adds the following to the original:

Usage

Start everything:

docker-compose up

Add some transactions:

curl "localhost:5001/transaction" \
     -H "Content-Type: application/json" \
     -d '{"from": "alice", "to":"bob", "amount": 3}'; \
curl "localhost:5002/transaction" \
     -H "Content-Type: application/json" \
     -d '{"from": "alice", "to":"pete", "amount": 5}'; \
curl "localhost:5003/transaction" \
     -H "Content-Type: application/json" \
     -d '{"from": "jeff", "to":"joe", "amount": 5}'; \
curl "localhost:5001/mine"; \
curl "localhost:5002/mine"; \
curl "localhost:5003/mine"

node1 has the longest chain.

Check the output, it should be the same on each node:

curl localhost:5001/blocks | jq
curl localhost:5002/blocks | jq
curl localhost:5003/blocks | jq

About

A tiny Python blockchain


Languages

Language:Python 100.0%