异步以太坊实用程序,

asynceth的Python项目详细描述


异步

异步以太坊jsonrpc库

安装

pip install asynceth

用法示例

import asyncio
from asynceth import JsonRPCClient
from asynceth import Contract

async def example_jsonrpc_request():
    client = JsonRPCClient("http://localhost:8485")
    balance = await client.eth_getBalance("0x0000000000000000000000000000000000000000")
    print(balance)

asyncio.get_event_loop().run_until_complete(example_jsonrpc_request())

greeter_code = """
contract Greeter is Mortal {
    /* Define variable greeting of the type string */
    string greeting;

    /* This runs when the contract is executed */
    function Greeter(string _greeting) public {
        greeting = _greeting;
    }

    /* Main function */
    function greet() constant returns (string) {
        return greeting;
    }
}
"""

# NOTE: example requires `solc` to be installed, and private_key must be the private key to an
# account on the ethereum node pointed to by JsonRPCClient that has funds to deploy the contract
private_key = os.urandom(32)
async def example_contract_deployment():
    client = JsonRPCClient("http://localhost:8485")
    greeter = await Contract(client, greeter_code).set_signer(private_key).deploy("Hello World")
    greeting = await greeter.greet()
    assert greeting == "Hello World"

asyncio.get_event_loop().run_until_complete(example_contract_deployment())

运行测试

python setup.py test

virtualenv -p python3 env
env/bin/pip install -r requirements.txt -r requirements-testing.txt
env/bin/py.test

历史记录

0.0.1
  • 初始版本

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Clojure关键字在内存中的大小是多少?   Java中有固定长度的通用数组对象吗?   PostgreSQL:通过Java更新我的用户表   错误:使用java解析xml   java Json显示列表中对象的名称   java比较JodaTime时区   与JAVA中的API和包的区别?   java的int值在for循环中不改变   谷歌应用引擎中的java RSA   迁移到spring 5后出现java非法字符错误   java Websphere管理控制台不工作   JavaGSON如何始终在json中包含毫秒?   带有空格和双引号的windows Java ProcessBuilder命令参数失败   java错误:重复的zip条目[43.jar:org/apache/http/annotation/NotThreadSafe.class]