使用Python truffle 構建完整的智能合約
使用solidity的truffle框架開發智能合約,使用Python調用合約。
1. 合約編寫、編譯和部署
- git clone https://github.com/jamess010/AIonChain
- cd ./AIonChain && cd ./master/smartcontract
- truffle develop (port: 9545)
- compile
- migrate (--reset)
2. 使用 python 調用
- 安裝 web3.py 或者使用 docker web3.py
- cd ./notebook
- 將合約的 abi 編輯到 ./abis/ModelRepo.abi
- jupyter notebook
- 在 notebook 中打開 test_modelrepo.ipynb
- 更改 HTTPProvider 的地址
- 合約地址放到 contract_address 中