A simple blockchain REST API using FLASK
Live Site
- Clone the repo
git clone https://github.com/advistasyam/blockchain-concept
- Install PyPi packages
pip install -r requirements.txt
- Run Server
python blockchain.py <PORTNUMBER>
-
"/" Response Example:
{ "chain": [ { "hash_of_previous_block": "b085f0847895b23e0c565578283e70ea4b39ffc430fbcbbb7227b24e93838961", "index": 0, "nonce": 112756, "timestamp": 1625148147.788609, "transaction": [] }, { "hash_of_previous_block": "4d7ea7f44d7d294a86db91a5f1f59e9d2dcfdab4ad29a76cdbb68f96e7920f86", "index": 1, "nonce": 6461, "timestamp": 1625148205.64302, "transaction": [ { "amount": 25, "recipient": "bayu", "sender": "adit" }, { "amount": 50, "recipient": "dimas", "sender": "caca" }, { "amount": 5, "recipient": "89facc696dfa455c89eb2c04dcfc1515", "sender": "0" } ] } ], "length": 2 }
-
"/transactions/new", Requested Body: {amount, reciepient, sender}. Response Example :
{ "message": "Transaksi akan dimasukkan ke blok ke 1" }
-
"/mine"
{ "hash_of_previous_block": "4d7ea7f44d7d294a86db91a5f1f59e9d2dcfdab4ad29a76cdbb68f96e7920f86", "index": 1, "message": "A new block has been added", "nonce": 6461, "transactions": [ { "amount": 25, "recipient": "bayu", "sender": "adit" }, { "amount": 50, "recipient": "dimas", "sender": "caca" }, { "amount": 5, "recipient": "89facc696dfa455c89eb2c04dcfc1515", "sender": "0" } ] }
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch with your name (
git checkout -b yourname/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin yourname/AmazingFeature
) - Open a Pull Request