Skip to content
/ pymeca Public

A python package for interacting with the MECAnywhere smart contracts.

License

Notifications You must be signed in to change notification settings

sbip-sg/pymeca

Repository files navigation

pymeca

A python package for interacting with the MECAnywhere smart contracts

Installation

pip install pymeca

Build from source

git clone https://github.com/sbip-sg/pymeca.git
cd pymeca
git submodule init
git submodule update --recursive
pip install poetry
poetry install

Run tests

Requirements: poetry

pip install poetry
poetry install
cd ./mecanywhere_contracts/src/ganach && npm install

Requirements: node.js 20.11.1 and npm (tested with 8.5.5)

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="${HOME}/.nvm" && ."$NVM_DIR/nvm.sh"
cd mecanywhere_contracts/src/ganache && nvm install .nvmrc && nvm use .nvmrc && nvm install-latest-npm && npm install

From the main directory:

poetry shell
pytest

Usage

Launch the ganache test chain in a terminal to watch

cd src/pymeca/scripts
python3 ganache.py \
--host http://localhost \
--port 9000 \
--ganache-server-script-path ../../../mecanywhere_contracts/src/ganache/index.js \
--generate-accounts \
--accounts_file_path ../../config/accounts.json \
--dao-address-file-path ../dao_contract_address.txt \
--dao-file-path \
../../../mecanywhere_contracts/src/contracts/MecaContract.sol \
--scheduler-file-path \
../../../mecanywhere_contracts/src/contracts/SchedulerContract.sol \
--host-file-path \
../../../mecanywhere_contracts/src/contracts/HostContract.sol \
--tower-file-path \
../../../mecanywhere_contracts/src/contracts/TowerContract.sol \
--task-file-path \
../../../mecanywhere_contracts/src/contracts/TaskContract.sol \
--scheduler-fee 100 \
--host-register-fee 100 \
--host-initial-stake 100 \
--host-task-register-fee 100 \
--host-failed-task-penalty 100 \
--tower-initial-stake 100 \
--tower-host-request-fee 100 \
--tower-failed-task-penalty 100 \
--task-addition-fee 100
  • A sample workflow of how DAO entities interact with each other is provided here. The sample assumes that a ganache chain launched with the sample commands with ganache.py to setup corresponding accounts.

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

pymeca was created by Stefan-Dan Ciocirlan (sdcioc). It is licensed under the terms of the MIT license.

Credits

pymeca was created with cookiecutter and the py-pkgs-cookiecutter template.