Hyperledger Fabric Chaincode shim and Contract API for Python.
- Experimental implementation of a Python chaincode shim and contract API.
- CI runs with Python 3.11; supported Python versions are 3.10 and 3.11.
- Python 3.10+ (3.11 recommended)
- See
requirements.txtfor runtime dependencies. Key packages:grpcio==1.83.1protobuf>=7.35.1grpclib==0.4.3
Clone the repository and create a virtual environment:
git clone https://github.com/kmilodenisglez/fabric-chaincode-python.git
cd fabric-chaincode-python
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txtRun tests:
pytest -qBuild a wheel that can be published or installed:
python -m pip install --upgrade build
python -m build --wheel --no-isolation
# artifact will be in dist/*.whlThis repository contains generated Python protobuf bindings for Hyperledger
Fabric under the fabric_protos_python/ package. The project also includes a
scripts/gen_protos.sh helper to regenerate bindings from the fabric-protos
source (recommended to use a pinned tag/submodule for reproducible results).
If you regenerate protos in CI or locally, ensure the protobuf runtime used
to generate the files is compatible with the installed protobuf package
(see requirements.txt).
Set the environment variables expected by the example chaincode server:
export CHAINCODE_ID=basic_1.0:your_package_id_here
export CHAINCODE_SERVER_ADDRESS=127.0.0.1:9999Then start the example service (if main.py or an example is present):
python main.py- Follow the Developer Certificate of Origin (DCO): sign commits with
Signed-off-by: Your Name <you@example.com>(the repository contains a DCO check workflow). - The project uses the Apache-2.0 license.
For information on how to create releases and publish to PyPI, see RELEASING.md.
- RELEASING.md — Release process and PyPI publishing
- PROTOS.md — Guidance on handling Fabric protobufs
scripts/gen_protos.sh— Protobuf binding regeneration instructions