# Chainmaker-Python-SDK
[[长安链]](https://chainmaker.org.cn/)Python SDK。基于gRPC及[chainmaker/pb](https://git.chainmaker.org.cn/chainmaker/sdk-python)(protos)的链客户端。
提供链查询、链配置、用户合约管理、证书管理、公钥管理、订阅管理、多签管理、归档、Gas管理、交易池查询、DPos Erc20、DPos Stake、隐私计算等操作。
[sdk-python开源仓库地址](https://git.chainmaker.org.cn/chainmaker/sdk-python)
## 特性
- [x] 支持PermissionedWithCert、PermissionedWithKey、Public三种模式
- [x] 支持链查询,查询区块信息、区块头、区块高度、交易信息等
- [x] 支持查询链配置,更新核心配置、区块配置,增加修改删除信任根证书,增加修改共识节点等
- [x] 支持用户合约操作,合约查询、创建、更新、调用、查询、冻结、解冻、吊销等
- [x] 支持证书管理、证书哈希、证书别名管理及公钥管理
- [x] 支持Gas管理,查询设置Gas管理员,查询Gas账户状态、余额,Gas充值、退款等操作
- [x] 支持DPos Erc20及DPos Stake相关操作
- [x] 支持交易池状态查询
- [x] 支持区块订阅、交易合约及订阅合约事件
- [x] 支持多签请求、投票、查询等,支持多签手动运行及自动运行
- [x] 支持交易黑名单功能
- [x] 支持隐私计算
- [x] 支持国密非TLS场景(如,Public模式+国密)
## 安装方法
> chainmaker-python-sdk支持 python3.6~python3.10, 已知python3.11安装pysha3存在问题
**在线安装**
```shell
$ pip install chainmaker==2.3.2
```
**源码安全**
```shell
$ pip install git+https://git.chainmaker.org.cn/chainmaker/sdk-python.git@v2.3.2_qc
```
## 使用方法
### 以配置文件形式创建ChainClient
```python
from chainmaker import ChainClient
# 创建链客户端
cc = ChainClient.from_conf('./testdata/sdk_config.yml')
# 获取链版本
print(cc.get_chainmaker_server_version())
```
> 注: sdk_config.yml中私钥/证书等如果使用相对路径应相对于当前运行起始目录
> [配置文件 sdk_config.yml 格式参考](https://docs.chainmaker.org.cn/operation/配置文件一览.html#sdk-config-yml)
### 以参数形式创建ChainClient
```python
from chainmaker import Node, User, ChainClient
crypto_config_path = './testdata/crypto-config'
node_addr = '127.0.0.1:12301'
def read_file_bytes(file_path):
return open(file_path, 'rb').read()
# 创建签名用户
user = User(
org_id='wx-org1.chainmaker.org',
sign_key_bytes=read_file_bytes(f'{crypto_config_path}/wx-org1.chainmaker.org/user/client1/client1.tls.key'),
sign_cert_bytes=read_file_bytes(f'{crypto_config_path}/wx-org1.chainmaker.org/user/client1/client1.tls.crt'),
tls_key_bytes=read_file_bytes(f'{crypto_config_path}/wx-org1.chainmaker.org/user/client1/client1.sign.key'),
tls_cert_bytes=read_file_bytes(f'{crypto_config_path}/wx-org1.chainmaker.org/user/client1/client1.sign.crt')
)
# 创建连接节点
node = Node(
node_addr=node_addr,
conn_cnt=1,
enable_tls=True,
trust_cas=[read_file_bytes(f'{crypto_config_path}/wx-org1.chainmaker.org/ca'),
read_file_bytes(f'{crypto_config_path}/wx-org2.chainmaker.org/ca')],
tls_host_name='chainmaker.org'
)
# 创建链客户端
cc = ChainClient(chain_id='chain1', user=user, nodes=[node])
# 获取链版本
print(cc.get_chainmaker_server_version())
```
### 创建wasm合约
```python
from chainmaker import ChainClient, RuntimeType
crypto_config_path = './testdata/crypto-config'
# 背书用户配置
endorsers_config = [
{'org_id': 'wx-org1.chainmaker.org',
'user_sign_crt_file_path': f'{crypto_config_path}/wx-org1.chainmaker.org/user/admin1/admin1.sign.crt',
'user_sign_key_file_path': f'{crypto_config_path}/wx-org1.chainmaker.org/user/admin1/admin1.sign.key'},
{'org_id': 'wx-org2.chainmaker.org',
'user_sign_crt_file_path': f'{crypto_config_path}/wx-org2.chainmaker.org/user/admin1/admin1.sign.crt',
'user_sign_key_file_path': f'{crypto_config_path}/wx-org2.chainmaker.org/user/admin1/admin1.sign.key'},
{'org_id': 'wx-org3.chainmaker.org',
'user_sign_crt_file_path': f'{crypto_config_path}/wx-org3.chainmaker.org/user/admin1/admin1.sign.crt',
'user_sign_key_file_path': f'{crypto_config_path}/wx-org3.chainmaker.org/user/admin1/admin1.sign.key'},
]
cc = ChainClient.from_conf('./testdata/sdk_config.yml')
# 创建WASM合约,本地合约文件./testdata/contracts/rust-fact-2.0.0.wasm应存在
payload = cc.create_contract_create_payload(
contract_name='fact',
version='1.0',
byte_code_or_file_path='./testdata/contracts/rust-fact-2.0.0.wasm',
runtime_type=RuntimeType.WASMER,
params={})
# 创建背书
endorsers = cc.create_endorsers(payload, endorsers_config)
# 发送创建合约请求
tx_response = cc.send_contract_manage_request(payload, endorsers=endorsers, with_sync_result=True)
print(tx_response)
```
### 创建evm合约
```python
from chainmaker import ChainClient, RuntimeType
crypto_config_path = './testdata/crypto-config'
# 背书用户配置
endorsers_config = [
{'org_id': 'wx-org1.chainmaker.org',
'user_sign_crt_file_path': f'{crypto_config_path}/wx-org1.chainmaker.org/user/admin1/admin1.sign.crt',
'user_sign_key_file_path': f'{crypto_config_path}/wx-org1.chainmaker.org/user/admin1/admin1.sign.key'},
{'org_id': 'wx-org2.chainmaker.org',
'user_sign_crt_file_path': f'{crypto_config_path}/wx-org2.chainmaker.org/user/admin1/admin1.sign.crt',
'user_sign_key_file_path': f'{crypto_config_path}/wx-org2.chainmaker.org/user/admin1/admin1.sign.key'},
{'org_id': 'wx-org3.chainmaker.org',
'user_sign_crt_file_path': f'{crypto_config_path}/wx-org3.chainmaker.org/user/admin1/admin1.sign.crt',
'user_sign_key_file_path': f'{crypto_config_path}/wx-org3.chainmaker.org/user/admin1/admin1.sign.key'},
]
cc = ChainClient.from_conf('./testdata/sdk_config.yml')
# 创建EVM合约,本地合约文件./testdata/contracts/ledger_balance.bin应存在
payload = cc.create_contract_create_payload(
contract_name='balance001',
version='1.0',
byte_code_or_file_path='./testdata/contracts/ledger_balance.bin',
runtime_type=RuntimeType.EVM)
# 创建背书
endorsers = cc.create_endorsers(payload, endorsers_config)
# 发送创建合约请求
tx_response = cc.send_contract_manage_request(payload, endorsers=endorsers, with_sync_result=True)
print(tx_response)
```
### 调用wasm合约
```python
from chainmaker.chain_client import ChainClient
from chainmaker.utils.evm_utils import calc_evm_method_params
# 创建客户端
cc = ChainClient.from_conf('./testdata/sdk_config.yml')
# 调用WASM合约
tx_response = cc.invoke_contract(
contract_name='fact',
method='save',
params={"file_name": "name007", "file_hash": "ab3456df5799b87c77e7f88", "time": "6543234"},
with_sync_result=True)
print(tx_response)
```
### 调用evm合约
```python
from chainmaker.chain_client import ChainClient
from chainmaker.utils.evm_utils import calc_evm_method_params
# 创建客户端
cc = ChainClient.from_conf('./testdata/sdk_config.yml')
# 调用EVM合约
evm_contract_name = 'balance001' # EVM合约名不再需要进行转换
evm_method, evm_params = calc_evm_method_params(
method='updateBalance',
params=[{"uint256": "10000"}, {"address": "0xa166c92f4c8118905ad984919dc683a7bdb295c1"}])
tx_response = cc.invoke_contract(
contract_name=evm_contract_name,
method=evm_method,
params=evm_params,
with_sync_result=True)
print(tx_response)
```
### 更多示例和用法
> 更多示例和用法,请参考单元测试用例
| 功能 | 单测代码 |
|-------|---------------------------------|
| 用户合约 | `tests/test_user_contract.py` |
| 系统合约 | `tests/test_system_contract.py` |
| 链配置 | `tests/test_chain_config.py` |
| 证书管理 | `tests/test_cert_manage.py` |
| 消息订阅 | `tests/test_user_contract.py` |
## 接口说明
详细参考: [SDK接口文档](SDK_INTERFACES.md)
## 变更纪录
详细参考[CHANGELOG](CHANGELOG.md)
## 如何运行测试
1. 安装测试需要的依赖
```shell
pip install -r requirements-test.txt
```
2. 下载并拷贝被测环境的crypto-config到tests/resources/目录下
3. 修改tests/resources/sdk_config.yml中的节点地址或修改tests/pytest.ini中是sdk_config配置指定sdk_config.yml路径
4. 运行测试
```shell
pytest tests
```
## 如何进行开发
1. 安装依赖
```shell
pip install requirements-dev
```
更新protos
```shell
make proto
```
测试覆盖率
```shell
make coverage
```
检查代码
```shell
make lint
```
发布
```shell
make release
```
## TODO
- [ ] 支持国密TLS
- [ ] 实现Hibe加密
## 已知问题
- [ ] 使用Python3.11安装时,pysha3会build失败,可以改为Python3.6~python3.10,建议使用Python3.9
- [ ] 使用管理台部署的链,使用sdk-python连接报错(使用sdk-go能连接),可能原因为管理台生成的证书扩展SAN(SubjectAlternativeName)中不包含部署服务的域名导致OpenSSL验证失败所致(sdk-go不验证该项),可以尝试在sdk_config.yml的tls_host_name修改为你的域名,或尝试使用
[chainmaker-cryptogen](https://git.chainmaker.org.cn/chainmaker/chainmaker-cryptogen)项目生成证书。
## 参考
- [chainmaker-docs](https://docs.chainmaker.org.cn/index.html)
- [gRPC Python](https://grpc.github.io/grpc/python)
- [grpcio](https://grpc.io/docs/languages/python/quickstart/)
- [cryptography](https://cryptography.io/)
- [eth-abi](https://eth-abi.readthedocs.io/en/latest/)
Raw data
{
"_id": null,
"home_page": "https://git.chainmaker.org.cn/chainmaker/chainmaker-sdk-python.git",
"name": "chainmaker-sdk-python",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "chainmaker,blockchain,chainmaker-sdk-python,chainmaker-sdk",
"author": "THL chainmaker developers",
"author_email": "operation@chainmaker.org",
"download_url": "https://files.pythonhosted.org/packages/67/c4/d92171a3f3ddb7795869a71fe957d33a3fe0225ab2f0cb074c719730aad1/chainmaker-sdk-python-2.3.2.tar.gz",
"platform": null,
"description": "# Chainmaker-Python-SDK\n\n[[\u957f\u5b89\u94fe]](https://chainmaker.org.cn/)Python SDK\u3002\u57fa\u4e8egRPC\u53ca[chainmaker/pb](https://git.chainmaker.org.cn/chainmaker/sdk-python)(protos)\u7684\u94fe\u5ba2\u6237\u7aef\u3002\n\u63d0\u4f9b\u94fe\u67e5\u8be2\u3001\u94fe\u914d\u7f6e\u3001\u7528\u6237\u5408\u7ea6\u7ba1\u7406\u3001\u8bc1\u4e66\u7ba1\u7406\u3001\u516c\u94a5\u7ba1\u7406\u3001\u8ba2\u9605\u7ba1\u7406\u3001\u591a\u7b7e\u7ba1\u7406\u3001\u5f52\u6863\u3001Gas\u7ba1\u7406\u3001\u4ea4\u6613\u6c60\u67e5\u8be2\u3001DPos Erc20\u3001DPos Stake\u3001\u9690\u79c1\u8ba1\u7b97\u7b49\u64cd\u4f5c\u3002\n\n[sdk-python\u5f00\u6e90\u4ed3\u5e93\u5730\u5740](https://git.chainmaker.org.cn/chainmaker/sdk-python)\n\n## \u7279\u6027\n- [x] \u652f\u6301PermissionedWithCert\u3001PermissionedWithKey\u3001Public\u4e09\u79cd\u6a21\u5f0f\n- [x] \u652f\u6301\u94fe\u67e5\u8be2,\u67e5\u8be2\u533a\u5757\u4fe1\u606f\u3001\u533a\u5757\u5934\u3001\u533a\u5757\u9ad8\u5ea6\u3001\u4ea4\u6613\u4fe1\u606f\u7b49\n- [x] \u652f\u6301\u67e5\u8be2\u94fe\u914d\u7f6e,\u66f4\u65b0\u6838\u5fc3\u914d\u7f6e\u3001\u533a\u5757\u914d\u7f6e,\u589e\u52a0\u4fee\u6539\u5220\u9664\u4fe1\u4efb\u6839\u8bc1\u4e66,\u589e\u52a0\u4fee\u6539\u5171\u8bc6\u8282\u70b9\u7b49\n- [x] \u652f\u6301\u7528\u6237\u5408\u7ea6\u64cd\u4f5c,\u5408\u7ea6\u67e5\u8be2\u3001\u521b\u5efa\u3001\u66f4\u65b0\u3001\u8c03\u7528\u3001\u67e5\u8be2\u3001\u51bb\u7ed3\u3001\u89e3\u51bb\u3001\u540a\u9500\u7b49\n- [x] \u652f\u6301\u8bc1\u4e66\u7ba1\u7406\u3001\u8bc1\u4e66\u54c8\u5e0c\u3001\u8bc1\u4e66\u522b\u540d\u7ba1\u7406\u53ca\u516c\u94a5\u7ba1\u7406\n- [x] \u652f\u6301Gas\u7ba1\u7406,\u67e5\u8be2\u8bbe\u7f6eGas\u7ba1\u7406\u5458,\u67e5\u8be2Gas\u8d26\u6237\u72b6\u6001\u3001\u4f59\u989d,Gas\u5145\u503c\u3001\u9000\u6b3e\u7b49\u64cd\u4f5c\n- [x] \u652f\u6301DPos Erc20\u53caDPos Stake\u76f8\u5173\u64cd\u4f5c\n- [x] \u652f\u6301\u4ea4\u6613\u6c60\u72b6\u6001\u67e5\u8be2\n- [x] \u652f\u6301\u533a\u5757\u8ba2\u9605\u3001\u4ea4\u6613\u5408\u7ea6\u53ca\u8ba2\u9605\u5408\u7ea6\u4e8b\u4ef6\n- [x] \u652f\u6301\u591a\u7b7e\u8bf7\u6c42\u3001\u6295\u7968\u3001\u67e5\u8be2\u7b49\uff0c\u652f\u6301\u591a\u7b7e\u624b\u52a8\u8fd0\u884c\u53ca\u81ea\u52a8\u8fd0\u884c\n- [x] \u652f\u6301\u4ea4\u6613\u9ed1\u540d\u5355\u529f\u80fd\n- [x] \u652f\u6301\u9690\u79c1\u8ba1\u7b97\n- [x] \u652f\u6301\u56fd\u5bc6\u975eTLS\u573a\u666f(\u5982,Public\u6a21\u5f0f+\u56fd\u5bc6)\n\n## \u5b89\u88c5\u65b9\u6cd5\n\n> chainmaker-python-sdk\u652f\u6301 python3.6~python3.10, \u5df2\u77e5python3.11\u5b89\u88c5pysha3\u5b58\u5728\u95ee\u9898\n\n**\u5728\u7ebf\u5b89\u88c5**\n\n```shell\n$ pip install chainmaker==2.3.2\n```\n\n**\u6e90\u7801\u5b89\u5168**\n```shell\n$ pip install git+https://git.chainmaker.org.cn/chainmaker/sdk-python.git@v2.3.2_qc\n```\n\n## \u4f7f\u7528\u65b9\u6cd5\n\n### \u4ee5\u914d\u7f6e\u6587\u4ef6\u5f62\u5f0f\u521b\u5efaChainClient\n\n```python\nfrom chainmaker import ChainClient\n# \u521b\u5efa\u94fe\u5ba2\u6237\u7aef\ncc = ChainClient.from_conf('./testdata/sdk_config.yml')\n# \u83b7\u53d6\u94fe\u7248\u672c\nprint(cc.get_chainmaker_server_version())\n```\n\n> \u6ce8: sdk_config.yml\u4e2d\u79c1\u94a5/\u8bc1\u4e66\u7b49\u5982\u679c\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84\u5e94\u76f8\u5bf9\u4e8e\u5f53\u524d\u8fd0\u884c\u8d77\u59cb\u76ee\u5f55\n> [\u914d\u7f6e\u6587\u4ef6 sdk_config.yml \u683c\u5f0f\u53c2\u8003](https://docs.chainmaker.org.cn/operation/\u914d\u7f6e\u6587\u4ef6\u4e00\u89c8.html#sdk-config-yml)\n\n### \u4ee5\u53c2\u6570\u5f62\u5f0f\u521b\u5efaChainClient\n\n```python\nfrom chainmaker import Node, User, ChainClient\n\ncrypto_config_path = './testdata/crypto-config'\nnode_addr = '127.0.0.1:12301'\n\ndef read_file_bytes(file_path):\n return open(file_path, 'rb').read()\n\n# \u521b\u5efa\u7b7e\u540d\u7528\u6237\nuser = User(\n org_id='wx-org1.chainmaker.org',\n sign_key_bytes=read_file_bytes(f'{crypto_config_path}/wx-org1.chainmaker.org/user/client1/client1.tls.key'),\n sign_cert_bytes=read_file_bytes(f'{crypto_config_path}/wx-org1.chainmaker.org/user/client1/client1.tls.crt'),\n tls_key_bytes=read_file_bytes(f'{crypto_config_path}/wx-org1.chainmaker.org/user/client1/client1.sign.key'),\n tls_cert_bytes=read_file_bytes(f'{crypto_config_path}/wx-org1.chainmaker.org/user/client1/client1.sign.crt')\n)\n\n# \u521b\u5efa\u8fde\u63a5\u8282\u70b9\nnode = Node(\n node_addr=node_addr,\n conn_cnt=1,\n enable_tls=True,\n trust_cas=[read_file_bytes(f'{crypto_config_path}/wx-org1.chainmaker.org/ca'),\n read_file_bytes(f'{crypto_config_path}/wx-org2.chainmaker.org/ca')],\n tls_host_name='chainmaker.org'\n)\n\n# \u521b\u5efa\u94fe\u5ba2\u6237\u7aef\ncc = ChainClient(chain_id='chain1', user=user, nodes=[node])\n# \u83b7\u53d6\u94fe\u7248\u672c\nprint(cc.get_chainmaker_server_version())\n```\n\n### \u521b\u5efawasm\u5408\u7ea6\n\n```python\n\nfrom chainmaker import ChainClient, RuntimeType\n\ncrypto_config_path = './testdata/crypto-config'\n\n# \u80cc\u4e66\u7528\u6237\u914d\u7f6e\nendorsers_config = [\n {'org_id': 'wx-org1.chainmaker.org',\n 'user_sign_crt_file_path': f'{crypto_config_path}/wx-org1.chainmaker.org/user/admin1/admin1.sign.crt',\n 'user_sign_key_file_path': f'{crypto_config_path}/wx-org1.chainmaker.org/user/admin1/admin1.sign.key'},\n {'org_id': 'wx-org2.chainmaker.org',\n 'user_sign_crt_file_path': f'{crypto_config_path}/wx-org2.chainmaker.org/user/admin1/admin1.sign.crt',\n 'user_sign_key_file_path': f'{crypto_config_path}/wx-org2.chainmaker.org/user/admin1/admin1.sign.key'},\n {'org_id': 'wx-org3.chainmaker.org',\n 'user_sign_crt_file_path': f'{crypto_config_path}/wx-org3.chainmaker.org/user/admin1/admin1.sign.crt',\n 'user_sign_key_file_path': f'{crypto_config_path}/wx-org3.chainmaker.org/user/admin1/admin1.sign.key'},\n]\n\ncc = ChainClient.from_conf('./testdata/sdk_config.yml')\n\n\n# \u521b\u5efaWASM\u5408\u7ea6\uff0c\u672c\u5730\u5408\u7ea6\u6587\u4ef6./testdata/contracts/rust-fact-2.0.0.wasm\u5e94\u5b58\u5728\npayload = cc.create_contract_create_payload(\n contract_name='fact', \n version='1.0', \n byte_code_or_file_path='./testdata/contracts/rust-fact-2.0.0.wasm',\n runtime_type=RuntimeType.WASMER, \n params={})\n# \u521b\u5efa\u80cc\u4e66\nendorsers = cc.create_endorsers(payload, endorsers_config)\n# \u53d1\u9001\u521b\u5efa\u5408\u7ea6\u8bf7\u6c42\ntx_response = cc.send_contract_manage_request(payload, endorsers=endorsers, with_sync_result=True)\nprint(tx_response)\n```\n### \u521b\u5efaevm\u5408\u7ea6\n\n```python\nfrom chainmaker import ChainClient, RuntimeType\n\ncrypto_config_path = './testdata/crypto-config'\n\n# \u80cc\u4e66\u7528\u6237\u914d\u7f6e\nendorsers_config = [\n {'org_id': 'wx-org1.chainmaker.org',\n 'user_sign_crt_file_path': f'{crypto_config_path}/wx-org1.chainmaker.org/user/admin1/admin1.sign.crt',\n 'user_sign_key_file_path': f'{crypto_config_path}/wx-org1.chainmaker.org/user/admin1/admin1.sign.key'},\n {'org_id': 'wx-org2.chainmaker.org',\n 'user_sign_crt_file_path': f'{crypto_config_path}/wx-org2.chainmaker.org/user/admin1/admin1.sign.crt',\n 'user_sign_key_file_path': f'{crypto_config_path}/wx-org2.chainmaker.org/user/admin1/admin1.sign.key'},\n {'org_id': 'wx-org3.chainmaker.org',\n 'user_sign_crt_file_path': f'{crypto_config_path}/wx-org3.chainmaker.org/user/admin1/admin1.sign.crt',\n 'user_sign_key_file_path': f'{crypto_config_path}/wx-org3.chainmaker.org/user/admin1/admin1.sign.key'},\n]\n\ncc = ChainClient.from_conf('./testdata/sdk_config.yml')\n# \u521b\u5efaEVM\u5408\u7ea6\uff0c\u672c\u5730\u5408\u7ea6\u6587\u4ef6./testdata/contracts/ledger_balance.bin\u5e94\u5b58\u5728\npayload = cc.create_contract_create_payload(\n contract_name='balance001', \n version='1.0', \n byte_code_or_file_path='./testdata/contracts/ledger_balance.bin',\n runtime_type=RuntimeType.EVM)\n# \u521b\u5efa\u80cc\u4e66\nendorsers = cc.create_endorsers(payload, endorsers_config)\n# \u53d1\u9001\u521b\u5efa\u5408\u7ea6\u8bf7\u6c42\ntx_response = cc.send_contract_manage_request(payload, endorsers=endorsers, with_sync_result=True)\nprint(tx_response)\n```\n\n### \u8c03\u7528wasm\u5408\u7ea6\n\n```python\nfrom chainmaker.chain_client import ChainClient\nfrom chainmaker.utils.evm_utils import calc_evm_method_params\n\n# \u521b\u5efa\u5ba2\u6237\u7aef\ncc = ChainClient.from_conf('./testdata/sdk_config.yml')\n\n# \u8c03\u7528WASM\u5408\u7ea6\ntx_response = cc.invoke_contract(\n contract_name='fact',\n method='save',\n params={\"file_name\": \"name007\", \"file_hash\": \"ab3456df5799b87c77e7f88\", \"time\": \"6543234\"},\n with_sync_result=True)\n\nprint(tx_response)\n```\n\n### \u8c03\u7528evm\u5408\u7ea6\n\n```python\nfrom chainmaker.chain_client import ChainClient\nfrom chainmaker.utils.evm_utils import calc_evm_method_params\n\n# \u521b\u5efa\u5ba2\u6237\u7aef\ncc = ChainClient.from_conf('./testdata/sdk_config.yml')\n# \u8c03\u7528EVM\u5408\u7ea6\nevm_contract_name = 'balance001' # EVM\u5408\u7ea6\u540d\u4e0d\u518d\u9700\u8981\u8fdb\u884c\u8f6c\u6362\nevm_method, evm_params = calc_evm_method_params(\n method='updateBalance', \n params=[{\"uint256\": \"10000\"}, {\"address\": \"0xa166c92f4c8118905ad984919dc683a7bdb295c1\"}])\n\ntx_response = cc.invoke_contract(\n contract_name=evm_contract_name, \n method=evm_method, \n params=evm_params, \n with_sync_result=True)\n\nprint(tx_response)\n```\n\n### \u66f4\u591a\u793a\u4f8b\u548c\u7528\u6cd5\n\n> \u66f4\u591a\u793a\u4f8b\u548c\u7528\u6cd5\uff0c\u8bf7\u53c2\u8003\u5355\u5143\u6d4b\u8bd5\u7528\u4f8b\n\n| \u529f\u80fd | \u5355\u6d4b\u4ee3\u7801 |\n|-------|---------------------------------|\n| \u7528\u6237\u5408\u7ea6 | `tests/test_user_contract.py` |\n| \u7cfb\u7edf\u5408\u7ea6 | `tests/test_system_contract.py` |\n| \u94fe\u914d\u7f6e | `tests/test_chain_config.py` |\n| \u8bc1\u4e66\u7ba1\u7406 | `tests/test_cert_manage.py` |\n| \u6d88\u606f\u8ba2\u9605 | `tests/test_user_contract.py` |\n\n\n## \u63a5\u53e3\u8bf4\u660e\n\n\u8be6\u7ec6\u53c2\u8003: [SDK\u63a5\u53e3\u6587\u6863](SDK_INTERFACES.md)\n\n## \u53d8\u66f4\u7eaa\u5f55\n\n\u8be6\u7ec6\u53c2\u8003[CHANGELOG](CHANGELOG.md)\n\n## \u5982\u4f55\u8fd0\u884c\u6d4b\u8bd5\n\n\n1. \u5b89\u88c5\u6d4b\u8bd5\u9700\u8981\u7684\u4f9d\u8d56\n```shell\npip install -r requirements-test.txt\n```\n2. \u4e0b\u8f7d\u5e76\u62f7\u8d1d\u88ab\u6d4b\u73af\u5883\u7684crypto-config\u5230tests/resources/\u76ee\u5f55\u4e0b\n\n3. \u4fee\u6539tests/resources/sdk_config.yml\u4e2d\u7684\u8282\u70b9\u5730\u5740\u6216\u4fee\u6539tests/pytest.ini\u4e2d\u662fsdk_config\u914d\u7f6e\u6307\u5b9asdk_config.yml\u8def\u5f84\n\n4. \u8fd0\u884c\u6d4b\u8bd5\n```shell\npytest tests\n```\n\n## \u5982\u4f55\u8fdb\u884c\u5f00\u53d1\n\n1. \u5b89\u88c5\u4f9d\u8d56\n```shell\npip install requirements-dev\n```\n\n\u66f4\u65b0protos\n```shell\nmake proto\n```\n\n\n\u6d4b\u8bd5\u8986\u76d6\u7387\n```shell\nmake coverage\n```\n\n\u68c0\u67e5\u4ee3\u7801\n```shell\nmake lint\n```\n\n\u53d1\u5e03\n```shell\nmake release\n```\n\n## TODO\n- [ ] \u652f\u6301\u56fd\u5bc6TLS\n- [ ] \u5b9e\u73b0Hibe\u52a0\u5bc6\n\n## \u5df2\u77e5\u95ee\u9898\n- [ ] \u4f7f\u7528Python3.11\u5b89\u88c5\u65f6,pysha3\u4f1abuild\u5931\u8d25\uff0c\u53ef\u4ee5\u6539\u4e3aPython3.6\uff5epython3.10\uff0c\u5efa\u8bae\u4f7f\u7528Python3.9\n- [ ] \u4f7f\u7528\u7ba1\u7406\u53f0\u90e8\u7f72\u7684\u94fe\uff0c\u4f7f\u7528sdk-python\u8fde\u63a5\u62a5\u9519(\u4f7f\u7528sdk-go\u80fd\u8fde\u63a5)\uff0c\u53ef\u80fd\u539f\u56e0\u4e3a\u7ba1\u7406\u53f0\u751f\u6210\u7684\u8bc1\u4e66\u6269\u5c55SAN(SubjectAlternativeName)\u4e2d\u4e0d\u5305\u542b\u90e8\u7f72\u670d\u52a1\u7684\u57df\u540d\u5bfc\u81f4OpenSSL\u9a8c\u8bc1\u5931\u8d25\u6240\u81f4(sdk-go\u4e0d\u9a8c\u8bc1\u8be5\u9879),\u53ef\u4ee5\u5c1d\u8bd5\u5728sdk_config.yml\u7684tls_host_name\u4fee\u6539\u4e3a\u4f60\u7684\u57df\u540d,\u6216\u5c1d\u8bd5\u4f7f\u7528\n[chainmaker-cryptogen](https://git.chainmaker.org.cn/chainmaker/chainmaker-cryptogen)\u9879\u76ee\u751f\u6210\u8bc1\u4e66\u3002\n\n## \u53c2\u8003\n\n- [chainmaker-docs](https://docs.chainmaker.org.cn/index.html)\n- [gRPC Python](https://grpc.github.io/grpc/python)\n- [grpcio](https://grpc.io/docs/languages/python/quickstart/)\n- [cryptography](https://cryptography.io/)\n- [eth-abi](https://eth-abi.readthedocs.io/en/latest/)\n\n\n\n",
"bugtrack_url": null,
"license": "Apache License",
"summary": "ChainMaker Python SDK",
"version": "2.3.2",
"project_urls": {
"Homepage": "https://git.chainmaker.org.cn/chainmaker/chainmaker-sdk-python.git"
},
"split_keywords": [
"chainmaker",
"blockchain",
"chainmaker-sdk-python",
"chainmaker-sdk"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fc25c475937ddfe606489805625b331e5c1317f5d87664ebb6946263773ef60b",
"md5": "958b9230fc32d2898d2b918aafa8ea6c",
"sha256": "4375034fbf65af2604d6bf7032909deb519ab096b70a3b190e10003b76e4decf"
},
"downloads": -1,
"filename": "chainmaker_sdk_python-2.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "958b9230fc32d2898d2b918aafa8ea6c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 268562,
"upload_time": "2023-09-28T09:36:22",
"upload_time_iso_8601": "2023-09-28T09:36:22.145083Z",
"url": "https://files.pythonhosted.org/packages/fc/25/c475937ddfe606489805625b331e5c1317f5d87664ebb6946263773ef60b/chainmaker_sdk_python-2.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "67c4d92171a3f3ddb7795869a71fe957d33a3fe0225ab2f0cb074c719730aad1",
"md5": "886218ab9bd2f40fb86fd144d726fd77",
"sha256": "2bedf0d97d49f39a1a18e6a55ce8933d3ab3e3b0c3c66956f72e41ab8002f155"
},
"downloads": -1,
"filename": "chainmaker-sdk-python-2.3.2.tar.gz",
"has_sig": false,
"md5_digest": "886218ab9bd2f40fb86fd144d726fd77",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 27802,
"upload_time": "2023-09-28T09:36:24",
"upload_time_iso_8601": "2023-09-28T09:36:24.205333Z",
"url": "https://files.pythonhosted.org/packages/67/c4/d92171a3f3ddb7795869a71fe957d33a3fe0225ab2f0cb074c719730aad1/chainmaker-sdk-python-2.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-28 09:36:24",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "chainmaker-sdk-python"
}