Skip to content

rezamahdi/pyzantium

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages