{"id":27391437,"url":"https://github.com/maskedsyntax/block-lite","last_synced_at":"2025-04-13T20:46:37.593Z","repository":{"id":193907164,"uuid":"380504671","full_name":"MaskedSyntax/block-lite","owner":"MaskedSyntax","description":"A basic crypto coin in Python3 using hashlib (sha-256 encryption).","archived":false,"fork":false,"pushed_at":"2025-02-05T09:33:00.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T20:46:33.689Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/MaskedSyntax.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":"2021-06-26T13:10:13.000Z","updated_at":"2025-02-05T09:33:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"b9928ec9-47a4-4c6c-89a5-6010004c1579","html_url":"https://github.com/MaskedSyntax/block-lite","commit_stats":null,"previous_names":["aftaab25/crypto-coin","maskedsyntax/crypto-coin","maskedsyntax/block-lite"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaskedSyntax%2Fblock-lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaskedSyntax%2Fblock-lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaskedSyntax%2Fblock-lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaskedSyntax%2Fblock-lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaskedSyntax","download_url":"https://codeload.github.com/MaskedSyntax/block-lite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248782275,"owners_count":21160716,"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":[],"created_at":"2025-04-13T20:46:36.365Z","updated_at":"2025-04-13T20:46:37.580Z","avatar_url":"https://github.com/MaskedSyntax.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Block Lite\n\u003c!-- A basic crypto coin in Python3 using hashlib (sha-256 encryption). --\u003e\n\n\n## Simple Blockchain Implementation\n\nThis repository contains a simple implementation of a blockchain in Python. The code demonstrates the basic concepts of a blockchain, including block creation, mining, proof of work, and data validation.\n\n## Features\n\n- **Block Creation**: Each block contains an index, proof number, previous hash, data, and a timestamp.\n- **Proof of Work**: A simple proof-of-work algorithm is used to mine new blocks.\n- **Data Validation**: Ensures that each block is valid by checking the index, hash, proof, and timestamp.\n- **Mining Rewards**: Reward system for miners for creating new blocks.\n- **Node Management**: Ability to add nodes to the network.\n\n## Getting Started\n\n### Prerequisites\n\n- Python 3.x\n\n### Installation\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/yourusername/simple-blockchain.git\n   cd simple-blockchain\n   ```\n\n2. Run the blockchain script:\n   ```bash\n   python blockchain.py\n   ```\n\n### Usage\n\nThe script demonstrates the creation of a simple blockchain, mining of new blocks, and adding data to the blockchain.\n\n1. **Initialize the Blockchain**:\n   ```python\n   blockchain = BlockChain()\n   ```\n\n2. **Mine a New Block**:\n   ```python\n   print(\"***Mining Coinxyz about to start***\")\n   print(blockchain.chain)\n\n   last_block = blockchain.latest_block\n   last_proof_no = last_block.proof_no\n   proof_no = blockchain.proof_of_work(last_proof_no)\n\n   blockchain.new_data(\n       sender=\"0\",\n       recipient=\"Jane Doe\",\n       quantity=1,\n   )\n\n   last_hash = last_block.calculate_hash\n   block = blockchain.construct_block(proof_no, last_hash)\n\n   print(\"***Mining Coinxyz has been successful***\")\n   print(blockchain.chain)\n   ```\n\n3. **View the Blockchain**:\n   ```python\n   for block in blockchain.chain:\n       print(block)\n   ```\n\n## Code Overview\n\n### Block Class\n\nThe `Block` class represents a single block in the blockchain.\n\n- **Attributes**:\n  - `index`: The position of the block in the blockchain.\n  - `proof_no`: The proof number of the block.\n  - `prev_hash`: The hash of the previous block.\n  - `data`: The data stored in the block.\n  - `timestamp`: The time the block was created.\n\n- **Methods**:\n  - `calculate_hash`: Calculates the SHA-256 hash of the block.\n  - `__repr__`: Returns a string representation of the block.\n\n### BlockChain Class\n\nThe `BlockChain` class manages the entire blockchain.\n\n- **Attributes**:\n  - `chain`: A list of all the blocks in the blockchain.\n  - `current_data`: A list of data to be added to the next block.\n  - `nodes`: A set of nodes in the network.\n\n- **Methods**:\n  - `construct_genesis`: Creates the genesis block.\n  - `construct_block`: Adds a new block to the blockchain.\n  - `check_validity`: Validates a block against the previous block.\n  - `new_data`: Adds new data to the current data list.\n  - `proof_of_work`: Performs the proof-of-work algorithm.\n  - `verifying_proof`: Verifies the proof of a block.\n  - `latest_block`: Returns the latest block in the blockchain.\n  - `block_mining`: Mines a new block and rewards the miner.\n  - `create_node`: Adds a new node to the network.\n  - `obtain_block_object`: Creates a block object from block data.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaskedsyntax%2Fblock-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaskedsyntax%2Fblock-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaskedsyntax%2Fblock-lite/lists"}