diff --git a/blockchain_integration/pi_network/pi-stablecoin/routes/blockchain.py b/blockchain_integration/pi_network/pi-stablecoin/routes/blockchain.py new file mode 100644 index 000000000..f74d7e897 --- /dev/null +++ b/blockchain_integration/pi_network/pi-stablecoin/routes/blockchain.py @@ -0,0 +1,16 @@ +from flask import Blueprint, jsonify +from models import Blockchain + +blockchain_blueprint = Blueprint('blockchain', __name__) + +@blockchain_blueprint.route('/blockchain', methods=['GET']) +def get_blockchain(): + blockchain = Blockchain() + return jsonify(blockchain.chain) + +@blockchain_blueprint.route('/blockchain/add_block', methods=['POST']) +def add_block(): + blockchain = Blockchain() + new_block = Block(len(blockchain.chain), blockchain.get_latest_block().hash, int(time.time()), "New Block") + blockchain.add_block(new_block) + return jsonify(blockchain.chain)