Skip to main content

Python implementation and building blocks for blockchain

Project description

Pyzantium

Report Bug · Request Feature


🔗 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyzantium-0.0.2.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyzantium-0.0.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file pyzantium-0.0.2.tar.gz.

File metadata

  • Download URL: pyzantium-0.0.2.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.5

File hashes

Hashes for pyzantium-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ff53be6e75bc7b79d21a46ac389a71e8962bca161b3bfffdc7c54afefd2531aa
MD5 c4186ea6c66f92175cf59807c44de2e7
BLAKE2b-256 0882d0dd7c592ef8d9e2e8e7051b16c043979b802da05f09d46236e77f0f1f91

See more details on using hashes here.

File details

Details for the file pyzantium-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyzantium-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.5

File hashes

Hashes for pyzantium-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 51b188543fd605126f00fdccaebc74c721e365b6cdd7b615d634cfb52a65ed69
MD5 91009bf603f76b2f2b61ba533848fc45
BLAKE2b-256 b2d902832c24fd04939bfab8b949405159fdd8c6ba6dd02c64457e7dcf372e43

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page