{"id":23071318,"url":"https://github.com/0x4e3/simple-blockhain","last_synced_at":"2026-05-19T07:31:59.871Z","repository":{"id":88994620,"uuid":"105892745","full_name":"0x4e3/simple-blockhain","owner":"0x4e3","description":"Simple blockchain realisation with Flask API","archived":false,"fork":false,"pushed_at":"2017-10-05T13:34:56.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-09T00:24:53.517Z","etag":null,"topics":["blockchain","flask","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/0x4e3.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}},"created_at":"2017-10-05T13:22:26.000Z","updated_at":"2020-11-29T11:43:42.000Z","dependencies_parsed_at":"2023-06-13T11:45:37.548Z","dependency_job_id":null,"html_url":"https://github.com/0x4e3/simple-blockhain","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/0x4e3/simple-blockhain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x4e3%2Fsimple-blockhain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x4e3%2Fsimple-blockhain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x4e3%2Fsimple-blockhain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x4e3%2Fsimple-blockhain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0x4e3","download_url":"https://codeload.github.com/0x4e3/simple-blockhain/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x4e3%2Fsimple-blockhain/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33206316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-19T07:16:55.748Z","status":"ssl_error","status_checked_at":"2026-05-19T07:16:54.366Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["blockchain","flask","python"],"created_at":"2024-12-16T07:13:36.639Z","updated_at":"2026-05-19T07:31:59.855Z","avatar_url":"https://github.com/0x4e3.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-blockhain\nSimple blockchain realisation with Flask API.\n\n### Blockchain\n* main class `Blockchain`:  \n\n```python\nclass Blockchain(object):\n    def __init__(self):\n        self.chain = []\n        self.current_transactions = []\n\n        self.nodes = set()\n\n        # Generate genesis block\n        self.new_block(100, previous_hash=1)\n\n    def new_block(self, proof, previous_hash=None):\n        \"\"\"Creates new block in the Blockchain.\n\n        Arguments:\n            proof {int} -- Block's proof given by the Proof-of-Work algorithm.\n\n        Keyword Arguments:\n            previous_hash {str} -- Previous block's hash (default: {None}).\n\n        Returns:\n            dict -- The Block.\n        \"\"\"\n        ...\n\n    def new_transaction(self, sender, recipient, amount):\n        \"\"\"Creates new transaction to go to the next mined block.\n\n        Arguments:\n            sender {str} -- Address of the transaction's sender.\n            recipient {str} -- Address of the transaction's recipient.\n            amount {int} -- Transaction's amount.\n\n        Returns:\n            int -- The index of the block that will hold this transaction.\n        \"\"\"\n        ...\n\n    @staticmethod\n    def hash(block):\n        \"\"\"Creates a SHA-256 hash of a block.\n\n        Arguments:\n            block {dict} -- Block.\n\n        Returns:\n            str -- Hash string.\n        \"\"\"\n        ...\n\n    @property\n    def last_block(self):\n        ...\n\n    def proof_of_work(self, last_proof):\n        \"\"\"Simple Proof-of-Work algorithm.\n\n        - Find a number p' such that hash(pp') contains leading 4 zeroes,\n        where p is the previous p'\n        - p is the previous proof, and p' is the new proof\n\n        Arguments:\n            last_proof {int} -- Last valid proof.\n\n        Returns:\n            int -- Proof.\n        \"\"\"\n        ...\n\n    @staticmethod\n    def valid_proof(last_proof, proof):\n        \"\"\"Validates the Proof.\n\n        Does hash(last_proof, proof) contain 4 leading zeroes?\n\n        Arguments:\n            last_proof {int} -- Last valid proof.\n            proof {int} -- Current proof.\n\n        Returns:\n            bool -- True - if correct, False - otherwise.\n        \"\"\"\n        ...\n\n    def register_node(self, address):\n        \"\"\"Adds a new node to the list of nodes.\n\n        Arguments:\n            address {str} -- Address of node. Eg. 'http://192.168.0.5:5000'.\n        \"\"\"\n        ...\n\n    def valid_chain(self, chain):\n        \"\"\"Determines if a given blockchain is valid.\n\n        Arguments:\n            chain {list} -- A blockchain.\n\n        Returns:\n            bool -- True if valid, False - if not.\n        \"\"\"\n        ...\n\n    def resolve_conflicts(self):\n        \"\"\"This is our Consensus Algorithm.\n\n        It resolves conflicts by replacing our chain\n        with the longest one in the network.\n\n        Returns:\n            bool -- True if our chain was replaced, False if not.\n        \"\"\"\n        ...\n```\n\n* proof of work -- validates the new proof if SHA-256 hash of new proof and last proof has four leading zeroes:  \n\n```python\n@staticmethod\ndef valid_proof(last_proof, proof):\n    \"\"\"Validates the Proof.\n\n    Does hash(last_proof, proof) contain 4 leading zeroes?\n\n    Arguments:\n        last_proof {int} -- Last valid proof.\n        proof {int} -- Current proof.\n\n    Returns:\n        bool -- True - if correct, False - otherwise.\n    \"\"\"\n    guess = f'{last_proof}{proof}'.encode()\n    guess_hash = hashlib.sha256(guess).hexdigest()\n    return guess_hash[:4] == '0000'\n```\n\n### API endpoints\n* `/mine` -- mines new block\n* `/transactions/new` -- creates new transaction for the next mined block\n* `/chain` -- lists current chain\n* `/nodes` -- lists known blockchain nodes\n* `/nodes/register` -- register new node\n* `/consensus` -- checks all known nodes and compares own chain with other to find the longest valid chain\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0x4e3%2Fsimple-blockhain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0x4e3%2Fsimple-blockhain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0x4e3%2Fsimple-blockhain/lists"}