Web3.Py
0x-web3的Python项目详细描述
#py是web3的临时分支。它添加了对ABI元组的基本支持,这是为了方便调用0X智能合约所必需的。fork对web3.py的更改在打开的pr中可见,当该pr(或类似的东西)被合并时,此包将被删除。
[![加入聊天网站https://gitter.im/ethereum/web3.py](https://badges.gitter.im/ethereum/web3.py.svg)](https://gitter.im/ethereum/web3.py?utm_source=badge&utm_medium=badge&utm_campaign=pr badge&utm_content=badge
[![构建状态](https://circleci.com/gh/ethereum/web3.py.svg?style=shield)(https://circleci.com/gh/ethereum/web3.py.svg?style=shield)
*python 3.5+支持
[查看github上的更改日志](docs/releases.rst)。
testrpcprovider
来自solc import编译源代码
来自web3.contract import concisecontract
函数greeter(){
问候语='hello';
}
函数setgreeting(字符串问候语)public{
问候语='u greeting;
}
function greeting()常量返回(字符串){
返回问候语;
}
}
'
compiled_sol=compile_source(contract_source_code)compiled source code
contract_interface=compiled_sol['<;stdin>;:greeter']
web3.py实例
w3=web3(testrpcprovider())
字节码=协定接口['bin'])
"gas":410000})
=w3.eth.contract(address=contract廑address,abi=abi,contractFactoryClass=concisecontract)
web3.eth.contract对象的getters+setters
print('contract value:{}.format(contract廑instance.greet())
contract廑instance.setgreeting('nihao',transact={'from':w3.eth.accounts[0]}
print('setting value to:nihao')
print('contract value:{}'。format(contract戋instance.greet())
`````
有关以下内容的说明:
-[linux](docs/readme linux.md开发人员设置)
-[mac](docs/readme osx.md开发人员设置)
-[windows](docs/readme windows.md开发人员设置)
-[freebsd](docs/readme freebsd.md开发人员设置)
命令:
``sh
virtualenv venv
。venv/bin/activate
pip install-e.[dev]
```
对于不同的环境,可以设置多个"virtualenv"。例如,如果要创建"venvdocs",请执行以下操作:
``sh
virtualenv venvdocs
。venvdocs/bin/activate
pip install-e.[docs]
pip install-e.
`````
使用docker
如果您想在docker环境中开发和测试,请使用**docker compose.yml**文件中提供的*沙盒*容器。
启动测试环境,运行:
```
docker compose up-d
```
这将构建一个docker容器,该容器设置有运行python测试代码的环境。
**注意:此容器没有'go ethereum`已安装,因此无法运行go ethereum测试套件。**
"bash-c"前缀。
```
docker compose exec sandbox bash-c'
````
>或者,如果您只想打开到容器的会话,请运行:
````
```
```` `
测试在每个文件保存时运行。
每个python环境:
``sh
pip install py test watch
ptw--onfail"notify send-t 5000"test failure"python 3 test on web3.py failed"../tests../web3
```
或者,您可以在一个命令中运行多进程测试,但是如果没有颜色:
``sh
1.[设置开发环境](https://github.com/ethereum/web3.py/开发人员设置)。
2.对测试执行"tox"
测试有多个[组件](https://github.com/ethereum/web3.py/blob/master/.travis.yml l53)。您可以针对特定组件运行对的测试。例如:
``sh
添加"--recreate"参数。
`tox'有助于针对全套生成目标进行测试。但是如果您想单独运行测试,"py.test"更适合于开发工作流。例如,只运行一个文件中的测试:
``sh
py.test test tests/core/gas-strategies/test\u时间煤气价格策略。py
````
>
`` ` `发布安装程序
>制造release bump=$$version_part_to_bump$$
```
以及
`{major}.{minor}.{patch}-{stage}.{devnum}`表示不稳定(`stage`可以是alpha或beta)。
`将切换到稳定版本。
若要在当前版本稳定时发布不稳定版本,请显式指定新版本,如"make release bump="--new version 4.0.0-alpha.1 devnum"`
[![加入聊天网站https://gitter.im/ethereum/web3.py](https://badges.gitter.im/ethereum/web3.py.svg)](https://gitter.im/ethereum/web3.py?utm_source=badge&utm_medium=badge&utm_campaign=pr badge&utm_content=badge
[![构建状态](https://circleci.com/gh/ethereum/web3.py.svg?style=shield)(https://circleci.com/gh/ethereum/web3.py.svg?style=shield)
*python 3.5+支持
[查看github上的更改日志](docs/releases.rst)。
testrpcprovider
来自solc import编译源代码
来自web3.contract import concisecontract
函数greeter(){
问候语='hello';
}
函数setgreeting(字符串问候语)public{
问候语='u greeting;
}
function greeting()常量返回(字符串){
返回问候语;
}
}
'
compiled_sol=compile_source(contract_source_code)compiled source code
contract_interface=compiled_sol['<;stdin>;:greeter']
web3.py实例
w3=web3(testrpcprovider())
字节码=协定接口['bin'])
"gas":410000})
=w3.eth.contract(address=contract廑address,abi=abi,contractFactoryClass=concisecontract)
web3.eth.contract对象的getters+setters
print('contract value:{}.format(contract廑instance.greet())
contract廑instance.setgreeting('nihao',transact={'from':w3.eth.accounts[0]}
print('setting value to:nihao')
print('contract value:{}'。format(contract戋instance.greet())
`````
有关以下内容的说明:
-[linux](docs/readme linux.md开发人员设置)
-[mac](docs/readme osx.md开发人员设置)
-[windows](docs/readme windows.md开发人员设置)
-[freebsd](docs/readme freebsd.md开发人员设置)
命令:
``sh
virtualenv venv
。venv/bin/activate
pip install-e.[dev]
```
对于不同的环境,可以设置多个"virtualenv"。例如,如果要创建"venvdocs",请执行以下操作:
``sh
virtualenv venvdocs
。venvdocs/bin/activate
pip install-e.[docs]
pip install-e.
`````
使用docker
如果您想在docker环境中开发和测试,请使用**docker compose.yml**文件中提供的*沙盒*容器。
启动测试环境,运行:
```
docker compose up-d
```
这将构建一个docker容器,该容器设置有运行python测试代码的环境。
**注意:此容器没有'go ethereum`已安装,因此无法运行go ethereum测试套件。**
"bash-c"前缀。
```
docker compose exec sandbox bash-c'
````
>或者,如果您只想打开到容器的会话,请运行:
````
```
````
测试在每个文件保存时运行。
每个python环境:
``sh
pip install py test watch
```
或者,您可以在一个命令中运行多进程测试,但是如果没有颜色:
``sh
1.[设置开发环境](https://github.com/ethereum/web3.py/开发人员设置)。
2.对测试执行"tox"
测试有多个[组件](https://github.com/ethereum/web3.py/blob/master/.travis.yml l53)。您可以针对特定组件运行对的测试。例如:
``sh
添加"--recreate"参数。
`tox'有助于针对全套生成目标进行测试。但是如果您想单独运行测试,"py.test"更适合于开发工作流。例如,只运行一个文件中的测试:
``sh
py.test test tests/core/gas-strategies/test\u时间煤气价格策略。py
````
>
`` ` `发布安装程序
>制造release bump=$$version_part_to_bump$$
```
以及
`{major}.{minor}.{patch}-{stage}.{devnum}`表示不稳定(`stage`可以是alpha或beta)。
`将切换到稳定版本。
若要在当前版本稳定时发布不稳定版本,请显式指定新版本,如"make release bump="--new version 4.0.0-alpha.1 devnum"`