Implementation of ethereum smart contract read/write by web3.py and flask.
- Solidity
- Web3.py
- Flask
- Brownie
- Ganache
its required latest node and npm installed on local machine. this build work on any OS which support node and npm. install dependency by using command npm install in root folder.
Update .env file with below field
- export EMPLOYEE_SOL_FILE_PATH = "PATH to web3_learning_tutorials/reward_system/contracts/employee_contract.sol"
- export GANACHE_CONN = "http://127.0.0.1:<ganache_port>"
- export MY_ADDRESS = <account_address>
- export MY_PRIVATE_KEY = <private_key>
- export CHAIN_ID = <ganache_chain_id>
Run flask_server.py file using command
flask_server.py will compile code and deploye employee_contract.sol file on ganache. use url to view UI in browser http://localhost:5058
- http://localhost:5058/GetEmployeeData/
- http://localhost:5058/GetAllEmployeeData
- http://localhost:5058/AddEmployeeData
json payload : {"name":"John", "designation":"Engineer", "reward_amount":500}
reward_amount field is completely mendatory (default reward_amount : 1000) - http://localhost:5058/UpdateEmployeeData
json payload : {"id":0, "name":"John Pater", "designation":"Engineer"}
Update employee data will update only name OR designation.