Python implementation and building blocks for blockchain
Project description
Pyzantium
🔗 Python implementation and building blocks for blockchain
Pyzantium is a python module that let you implement blockchain whit various capabilityies in your project.
The Module provide both high-level(Blockchain
) and low-level(Block
,Consensus
, ...)
classes in order to be highly customizable.
1. Installation
The package is pip installable:
pip install pybchain
Or, you can download it and use setuptools
to build it by hand:
git clone http://github.com/rezamahdi/pybchain
cd pybchain
python setup.py install
2. Usage
To initialize a blockchain, you must specify some info as agreement:
- Hash algorithm to use in blockchain.
- Wath type of data you want to store. Blockchain is capable of storing anythin not only transactions.
- An authentication scheme. Common way to do this is using ECC. this part is optional.
- Endpoint to connect to other nodes. Common option is a HTTP api or json-rpc.
Whit having these options specified, you can initialize the node as this:
from pyzantium import Chain, Block
from pyzantium.storage import Disk
from hashlib import sha_256
chain = Chain(
hash=sha_256,
storage=Disk(
"path/to/storage",
create=True
)
)
Next, in order to mine genesis block do this:
genesis = Block(chain)
genesis.add_part(b'000000000000000000000000000') # or any other type of data.
# add more data parts...
genesis.finalize() # we don't use `mine` because it is named `forge` in PoS.
result = endpoint.broadcast_new_block(genesis)
if result.is_ok():
chain.append(genesis)
see documentation for more info
3. License
Copyright (c) Reza Mahdi 2022 This project is licensed under terms of MIT License (see LICENSE)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pyzantium-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51b188543fd605126f00fdccaebc74c721e365b6cdd7b615d634cfb52a65ed69 |
|
MD5 | 91009bf603f76b2f2b61ba533848fc45 |
|
BLAKE2b-256 | b2d902832c24fd04939bfab8b949405159fdd8c6ba6dd02c64457e7dcf372e43 |