{"id":28724432,"url":"https://github.com/giljr/python_blockchain_project","last_synced_at":"2025-07-21T10:05:24.804Z","repository":{"id":297431026,"uuid":"995562415","full_name":"giljr/python_blockchain_project","owner":"giljr","description":"We’ll explore how to create a fully functional blockchain from scratch using Python. We’ll walk through essential concepts such as block structure, Proof of Work, cryptographic hashing, and transaction handling.","archived":false,"fork":false,"pushed_at":"2025-06-05T11:41:48.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-15T10:53:10.150Z","etag":null,"topics":["block-structured","blockchain","blockchain-technology","criptography","cryptocurrency","hasshing-password","prof-of-work","python","python3","restful-api"],"latest_commit_sha":null,"homepage":"https://medium.com/jungletronics/building-a-simple-blockchain-with-python-and-flask-a95da7b5b713","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/giljr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-03T17:09:03.000Z","updated_at":"2025-06-05T11:45:50.000Z","dependencies_parsed_at":"2025-06-05T12:44:48.164Z","dependency_job_id":null,"html_url":"https://github.com/giljr/python_blockchain_project","commit_stats":null,"previous_names":["giljr/python_blockchain_project"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/giljr/python_blockchain_project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giljr%2Fpython_blockchain_project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giljr%2Fpython_blockchain_project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giljr%2Fpython_blockchain_project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giljr%2Fpython_blockchain_project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giljr","download_url":"https://codeload.github.com/giljr/python_blockchain_project/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giljr%2Fpython_blockchain_project/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266278376,"owners_count":23904041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["block-structured","blockchain","blockchain-technology","criptography","cryptocurrency","hasshing-password","prof-of-work","python","python3","restful-api"],"created_at":"2025-06-15T10:39:20.060Z","updated_at":"2025-07-21T10:05:24.798Z","avatar_url":"https://github.com/giljr.png","language":"Jupyter Notebook","readme":"### 🧱 Simple Blockchain with Transactions in Python\n\nA minimal blockchain implementation in Python featuring transaction support, Proof of Work, and a RESTful API powered by Flask.\n\n### 🚀 Features\n```\n\nBlockchain data structure with block linking via hashes.\n\nSimple Proof of Work (PoW) algorithm.\n\nTransaction pool integrated into mined blocks.\n\nRESTful API with endpoints to mine, view the chain, validate it, and add transactions.\n```\nDemonstrates fundamental blockchain concepts.\n\n#### 📝 Key Endpoints\n\nEndpoint\tMethod\tDescription\n```\n/mine_block\t        GET\tMines a new block and adds it to chain\n/get_chain\t        GET\tRetrieves the full blockchain\n/is_valid\t        GET\tValidates the blockchain integrity\n/add_transaction\tPOST\tAdds a new transaction\n```\n#### 🛠️ How It Works\nBlockchain Structure\nEach block contains:\n```\nindex\n\ntimestamp\n\nproof (Proof of Work)\n\nprevious_hash\n```\n#### transactions ✅\n\nTransactions\n```\nAdded via /add_transaction.\n```\nStored in a pending transaction pool.\n\nIncluded in the next mined block.\n\n#### Proof of Work\nSimple algorithm finding a number such that:\n```\nSHA256(new_proof² - previous_proof²) → hash starts with '00000'.\n```\n#### Validation\nEnsures each block's hash correctly references its predecessor and PoW is valid.\n\n#### ▶️ Getting Started\nClone the repo:\n```\ngit clone https://github.com/yourusername/blockchain-python.git\ncd blockchain-python\n```\nInstall dependencies:\n\n```python\n\npip install flask\n```\nRun the Flask app:\n\n```python\npython blockchain.py\n```\n\nAccess API at:\n\nhttp://127.0.0.1:5000\n\n#### 📦 Example Usage\nAdd a transaction:\n```curl\ncurl -X POST -H \"Content-Type: application/json\" \\\n-d '{\"sender\": \"Alice\", \"recipient\": \"Bob\", \"amount\": 50}' \\\nhttp://127.0.0.1:5000/add_transaction\n```\nMine a block:\n```curl\ncurl http://127.0.0.1:5000/mine_block\n```\nCheck the chain:\n```curl\ncurl http://127.0.0.1:5000/get_chain\n```\n🖼️ Blockchain Flow\n```plaintext\n[User Input]\n  ↓\nnew_transaction(sender, recipient, amount)\n  ↓\n[Transactions Pool]\n  ↓\nmine_block()\n  ↓\n[Proof of Work]\n  ↓\n[create_block(proof, previous_hash, transactions)]\n  ↓\n[Append to Chain]\n  ↓\n[Clear Transactions]\n```\n#### 🧪 Testing with Postman\nOpen Postman → New → HTTP Request.\n\nSet method to POST.\n\nURL: http://127.0.0.1:5000/add_transaction.\n\nBody → raw → JSON:\n```plaintext\n{\n  \"sender\": \"Alice\",\n  \"recipient\": \"Bob\",\n  \"amount\": 50\n}\n```\n#### ❓ Need Help?\nIf you get stuck, please refer to my [page](https://medium.com/jungletronics/building-a-simple-blockchain-with-python-and-flask-a95da7b5b713).\n\n#### 🏁 Summary\n✅ Blockchain implemented from scratch.\n\n✅ Transactions added to blocks.\n\n✅ Simple Proof of Work.\n\n✅ REST API via Flask.\n\n✅ Testing with curl or Postman.\n\n\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiljr%2Fpython_blockchain_project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiljr%2Fpython_blockchain_project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiljr%2Fpython_blockchain_project/lists"}