Skip to content

dyne/petition-tp-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

51 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

petition-tp-python
Petition Transaction Processor for Hyperledger Sawtooth

Build Status Dyne.org



This repository implements the whole DECODEproject's Petition Pilot over the Sawtooth blockchain distributed by the Linux Foundation's Hyperledger consortium.

To facilitate the creation of transaction families based on Zenroom VM and the Zencode human-friendly language for smart-contracts, this TP uses the Sawtooth SDK in Python and the zenroom-py bindings.


🐝 API server

To run the http server locally, you need an ASGI server like hypercorn or uvicorn.

Also a python virtual environment with all the library dependencies is needed, follow the following instruction to set it up:

python3 -m venv venv

this creates a virtual environment inside the venv folder

source ./venv/bin/activate

this activate the virtual environment you'll see a prefix (venv) on your PS1 prompt. From now on the libraries you install goes into that folder and are not system wide and doesn't mess up things.

pip install --upgrade pip
pip install -e .

This upgrades the pip (package installer for python) to the latest version, and installs all the python dependencies for the petition-tp-python package.

pip install fastapi[all]
pip install hypercorn

This install the ASGI server into your virtual environment and the other needed dependencies to run the server

hypercorn src.tp.server.main:app

This runs the server on the 8000 port.

To see the OpenAPI (former SwaggerUI) head to http://localhost:8000/docs

ENV

to run the middleware some variable environment are needed, or you can use a dotenv (a file called .env in the root of the project) with the following content:

export JWT_ALGORITHM=HS256
export JWT_TOKEN_SUBJECT=access
export JWT_ACCESS_TOKEN_EXPIRE_MINUTES=30
export JWT_USERNAME=demo
export JWT_PASSWORD=demo
export JWT_RANDOM_SECRET=change_me_with_a_very_long_hex_string

the username and paswword are the ones used within the OpenAPI ui


🐳 Docker

docker-compose up --build

To run a transaction

docker exec -it petition-tp petition --help

shows you all the commands available of the little petition CLI interface

CREATE

docker exec -it petition-tp petition create --help

SIGN

docker exec -it petition-tp petition sign --help

SHOW

docker exec -it petition-tp petition show --help

TALLY

docker exec -it petition-tp petition tally --help

COUNT

docker exec -it petition-tp petition count --help

πŸ”§ Configuration

Configuration are passed along ENV variables or .dotenv files, the available variables are:

  • SAWTOOTH_VALIDATOR_ENDPOINT
  • SAWTOOTH_REST_ENDPOINT

😍 Acknowledgements

Copyright πŸ„― 2019 by Dyne.org foundation, Amsterdam

Designed, written and maintained by Puria Nafisi Azizi.

Project funded by the European Commission

This project is receiving funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement nr. 732546 (DECODE).


🌐 Links

https://zenroom.org/

https://decodeproject.eu/

https://dyne.org/


πŸ‘₯ Contributing

Please first take a look at the Dyne.org - Contributor License Agreement then

  1. πŸ”€ FORK IT
  2. Create your feature branch git checkout -b feature/branch
  3. Commit your changes git commit -am 'Add some fooBar'
  4. Push to the branch git push origin feature/branch
  5. Create a new Pull Request
  6. πŸ™ Thank you

πŸ’Ό License

Petition TP, Transaction processor for Decode Petition over sawtooth
Copyright (c) 2019 Dyne.org foundation, Amsterdam

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.