{"id":34600763,"url":"https://github.com/namecoder1/py_blockchain","last_synced_at":"2026-05-25T18:32:25.767Z","repository":{"id":288281823,"uuid":"967471251","full_name":"namecoder1/py_blockchain","owner":"namecoder1","description":"Blockchain in Python with CLI interface","archived":false,"fork":false,"pushed_at":"2025-04-16T14:10:38.000Z","size":1909,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-16T21:14:37.072Z","etag":null,"topics":["blockchain","python","tutorial"],"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/namecoder1.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-04-16T14:00:59.000Z","updated_at":"2025-04-16T14:10:41.000Z","dependencies_parsed_at":"2025-04-16T21:14:47.144Z","dependency_job_id":"7e0a9b8b-818d-45aa-8942-3b8227291406","html_url":"https://github.com/namecoder1/py_blockchain","commit_stats":null,"previous_names":["namecoder1/py_blockchain"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/namecoder1/py_blockchain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/namecoder1%2Fpy_blockchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/namecoder1%2Fpy_blockchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/namecoder1%2Fpy_blockchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/namecoder1%2Fpy_blockchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/namecoder1","download_url":"https://codeload.github.com/namecoder1/py_blockchain/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/namecoder1%2Fpy_blockchain/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33488810,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-25T14:31:05.219Z","status":"ssl_error","status_checked_at":"2026-05-25T14:31:02.878Z","response_time":57,"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","python","tutorial"],"created_at":"2025-12-24T12:41:53.851Z","updated_at":"2026-05-25T18:32:25.759Z","avatar_url":"https://github.com/namecoder1.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src='./assets/image.png' style='border-radius: 12px; width: full' /\u003e\n\n# Blockchain in Python\n\nA simple blockchain implementation in Python with a command-line interface for managing transactions between two users.\n\n## Features\n\n- Create and process transactions between users\n- Mine pending transactions into new blocks\n- Automatic fee calculation based on transaction amount and network load\n- Double-spending prevention\n- Transaction notes support\n- Colored terminal interface\n- JSON blockchain data persistence\n\n## Requirements\n\n- Python 3.13+\n- uv package manager\n- devbox\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/yourusername/py-blockchain.git\ncd py-blockchain\n```\n\n2. Install dependencies using uv:\n```bash\nuv pip install tabulate colorama\n```\n\n## Running with Docker\n\n1. Build the Docker image:\n```bash\ndocker build -t py-blockchain .\n```\n\n2. Run the container in interactive mode:\n```bash\ndocker run -it py-blockchain\n```\n\nTo persist blockchain data between runs, mount the blockchain_data.json file:\n```bash\ndocker run -it -v $(pwd)/blockchain_data.json:/app/blockchain_data.json py-blockchain\n```\n\n## Usage\n\n1. Start the application:\n```bash\nsource .venv/bin/activate\npython main.py\n```\n\n2. Available commands:\n   - Create transaction: Enter amount and optional note\n   - Mine pending transactions: Process pending transactions into a new block\n   - Print blockchain: View and save the current blockchain state\n   - Exit: Close the application\n\n## Project Structure\n\n- `main.py`: Main application entry point and CLI interface\n- `utils.py`: \n   - Core blockchain implementation (Block, Blockchain, Wallet) \n   - Utility functions for transaction handling and display\n   - Raw data to work with\n- `blockchain_data.json`: Appear after 'Print blockchain' (option 3 in CLI)\n\n## How It Works\n\n1. The blockchain starts with two users, each having an initial balance\n2. Transactions are created with:\n   - Sender and receiver addresses\n   - Amount\n   - Fee (automatically calculated)\n   - Optional note\n   - Timestamp\n3. Transactions are validated for:\n   - Sufficient balance\n   - No double-spending\n4. Pending transactions are mined into new blocks when:\n   - 10 transactions are pending\n   - User manually triggers mining\n5. Each block contains:\n   - Index\n   - Timestamp\n   - Transactions\n   - Previous block hash\n   - Current block hash\n   - Nonce (for mining)\n\n## Fee Calculation\n\nTransaction fees are calculated based on:\n- Base fee: 0.0010 BTC\n- Amount fee: 0.10% of transaction amount\n- Network load factor: Increases with more pending transactions\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamecoder1%2Fpy_blockchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnamecoder1%2Fpy_blockchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamecoder1%2Fpy_blockchain/lists"}