使用Python truffle 构建完整的智能合约

使用Python truffle 构建完整的智能合约


使用solidity的truffle框架开发智能合约,使用Python调用合约。


1)合约编写、编译和部署

1. git clone https://github.com/jamess010/AIonChain
2. cd ./AIonChain && cd ./master/smartcontract
3. truffle develop (port: 9545)
4. compile
5. migrate (--reset)

2)使用 python 调用
1. 安装 [web3.py](https://github.com/ethereum/web3.py) 或者使用 docker web3.py, 参见:[使用Docker Python 构建智能合约](https://www.aifirm.org/2019-08-01-Use-Docker-Python-Build-Smart-Contract/)
2. cd ./notebook
3. 将合约的 abi 编辑到 ./abis/ModelRepo.abi
4. jupyter notebook
5. 在 notebook 中打开 test_modelrepo.ipynb
6. 更改 HTTPProvider 的地址
7. 合约地址放到 contract_address 中
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值