Blockchain POC to CS50 final project Course Certificate.
Blockchain is a decentralized way to save data. In our case, as bitcoin works, the data is financial transactions. First is necessary for the user to create their wallet that's is a pair of RSA256 keys. These will work as address to receive deposits and authenticate withdraws. The API in itself is an abstraction to a Node, it is a piece of the network that decentralize the blockchain, it is responsible for submitting transactions to block and mine them. Mine means doing a proof of work calculation and being responsible for sending the new block to the blockchain. More details in CS50 Readme.
classDiagram
class Wallet {
public_key
private_key
financial_data
created_at
}
class Transaction {
sender_public_key
recipient_public_key
amount
description
sign
created_at
do_sign(sender_private_key)
}
class Node {
transactions
nodes
submit_transaction(transaction)
add_node_address(address)
sync()
mine_block()
}
class Block {
id
data
hash
nonce
created_at
}
- GET /api/node
- get current node transactions and other node addresses
- POST /api/node/address
- add new node address
- DELETE /api/node/transactions
- clear node transactions
- POST /api/node/mine
- mine block, aka sync transaction with other nodes, calculate nonce (proof of work), and create a new block to the blockchain
- GET /api/chain
- get blockchain
- POST /api/chain
- sync current node with other blockchain and transactions
- POST /api/wallet
- create new wallet
- POST /api/search/wallet
- wallet search
- POST /api/transaction
- submit transaction to node
To run the node locally run make docker-run
and then open on browser http://localhost:5000/ to interact with an interface.
To run another node to mock transactions and sync between them, use make docker-run APP_NAME=cs50chain-clone PORT=5001
and open http://localhost:5001/ .
Also can import the Postman Collection to request directly to the API.
To run tests make docker-test
Jun 14 2022
Name Stmts Miss Cover
----------------------------------------
app/__init__.py 0 0 100%
app/block.py 85 15 82%
app/config.py 8 0 100%
app/database.py 15 1 93%
app/node.py 79 18 77%
app/transaction.py 55 9 84%
app/wallet.py 58 1 98%
test/__init__.py 0 0 100%
test/test_app.py 107 0 100%
----------------------------------------
TOTAL 407 44 89%
If you want to persist data, run make docker-migration
and it'll create a local sqlite3 database. These commands can be used to run sql queries on the database.
- A Practical Introduction to Blockchain with Python
- On the Origins and Variations of Blockchain Technologies
- Bitcoin Whitepaper
- TypeScript Blockchain
- Code your own blockchain in less than 200 lines of Go!
- Learn Blockchains by Building One
- Best-README-Template
- infra
- add
Dockerfile
,make docker-build
and use build onmake docker-run
andmake docker-test
- add
- frontend
- add copy to clipboard button on table lines and copy object
- clickable link to expand with complete object
- documentation
- add swagger
- codeclimate
- online
- deploy app
- save blockchain on heroku postgresql