https://github.com/block-foundation/bitchain
Simple Blockchain emulator in Python for educational purposes.
https://github.com/block-foundation/bitchain
bitchain bitcoin block-foundation blockchain blockfoundation python
Last synced: 5 months ago
JSON representation
Simple Blockchain emulator in Python for educational purposes.
- Host: GitHub
- URL: https://github.com/block-foundation/bitchain
- Owner: block-foundation
- License: cc-by-sa-4.0
- Created: 2023-07-29T20:22:58.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-08T07:29:49.000Z (almost 2 years ago)
- Last Synced: 2025-09-04T21:49:24.600Z (9 months ago)
- Topics: bitchain, bitcoin, block-foundation, blockchain, blockfoundation, python
- Language: Python
- Homepage: https://pypi.org/project/bitchain/
- Size: 54.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Citation: CITATION.cff
- Codeowners: CODEOWNERS
- Security: SECURITY.md
- Support: SUPPORT.md
Awesome Lists containing this project
README
[](https://github.com/block-foundation/bitchain/blob/main/LICENSE)
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/block-foundation/bitchain)
---
Bitchain
A Simple Blockchain Emulator in Python
---

### Contents
- [Introduction](#introduction)
- [Colophon](#colophon)
---
[](https://github.com/block-foundation/bitchain/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=bug_report.yml)
[](https://github.com/block-foundation/bitchain/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=feature_request.yml)
[](https://github.com/block-foundation/bitchain/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=question.yml)
[](https://github.com/block-foundation/bitchain/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=suggestion.yml)
[](https://github.com/block-foundation/bitchain/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&projects=&template=discussion.yml)
## Introduction
Bitchain is a simple lockchain emulator written in Python. Aimed at fostering education and understanding of blockchain technologies, Bitchain provides a clear and easy-to-understand interface to interact with a blockchain.
### Key Features
- **Block Creation**: Easily create new blocks with customizable data.
- **Transaction Handling**: Simulate transactions between parties in the blockchain.
- **Chain Validation**: Verify the integrity of the blockchain through hash calculations.
- **Persistence**: Keep a record of transactions until they are incorporated into a block.
## Installation
### Requirements
- Python 3.6 or higher
- Git (optional)
To install Bitchain, clone the repository using Git:
``` sh
git clone https://github.com/username/bitchain.git
cd bitchain
```
or:
``` sh
pip install bitchain
```
see: https://pypi.org/project/bitchain/
You can also download the source code as a zip file and extract it.
## Usage
Once you have the Bitchain code on your local machine, you can run it using Python:
``` sh
python3 main.py
```
Bitchain includes a `main` function that creates a simple blockchain, adds transactions to it, and prints out the entire chain.
## Example
Here's a quick example of creating a blockchain, adding transactions, and creating new blocks:
``` python
blockchain = Bitchain()
blockchain.new_transaction("Satoshi", "Mike", '5 BTC')
blockchain.new_transaction("Mike", "Satoshi", '1 BTC')
blockchain.new_transaction("Satoshi", "Hal Finney", '5 BTC')
blockchain.new_block(12345)
blockchain.new_transaction("Mike", "Alice", '1 BTC')
blockchain.new_transaction("Alice", "Bob", '0.5 BTC')
blockchain.new_transaction("Bob", "Mike", '0.5 BTC')
blockchain.new_block(6789)
print("Genesis block: ", blockchain.chain)
```
## Building
``` py
python3 -m pip install --upgrade build
python3 -m build
```
## Documentation
Please refer to the docstrings in the `Bitchain` class for detailed information on the functionality of each method.
---
## Colophon
### Authors
This is an open-source project by the **[Block Foundation](https://www.blockfoundation.io "Block Foundation website")**.
The Block Foundation mission is enabling architects to take back initiative and contribute in solving the mismatch in housing through blockchain technology. Therefore the Block Foundation seeks to unschackle the traditional constraints and construct middle ground between rent and the rigidity of traditional mortgages.
website: [www.blockfoundation.io](https://www.blockfoundation.io "Block Foundation website")
### Development Resources
#### Contributing
We'd love for you to contribute and to make this project even better than it is today!
Please refer to the [contribution guidelines](.github/CONTRIBUTING.md) for information.
### Legal Information
#### Copyright
Copyright © 2023 [Stichting Block Foundation](https://www.blockfoundation.io/ "Block Foundation website"). All Rights Reserved.
#### License
Except as otherwise noted, the content in this repository is licensed under the
[Creative Commons Attribution 4.0 International (CC BY 4.0) License](https://creativecommons.org/licenses/by/4.0/), and
code samples are licensed under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).
Also see [LICENSE](https://github.com/block-foundation/community/blob/master/src/LICENSE) and [LICENSE-CODE](https://github.com/block-foundation/community/blob/master/src/LICENSE-CODE).
#### Disclaimer
**THIS SOFTWARE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**