Asyncio Ethereum Utilities
Project description
asynceth
An asyncio ethereum jsonrpc library
Install
pip install asynceth
Usage Example
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())
Running tests
python setup.py test
OR
virtualenv -p python3 env
env/bin/pip install -r requirements.txt -r requirements-testing.txt
env/bin/py.test
History
0.0.1
- Initial release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
asynceth-0.0.10.tar.gz
(13.7 kB
view hashes)
Built Distribution
asynceth-0.0.10-py3-none-any.whl
(16.7 kB
view hashes)
Close
Hashes for asynceth-0.0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 796cb71d7a429756e5a817b1b930e26fe9cf50a35103700d38622dce75c16832 |
|
MD5 | 1c7b65751d293146d57712fe8a69deab |
|
BLAKE2b-256 | 9738fb356b7a87c005bfc695092ca22fc40b0f3f88df6d5836900633b5704d76 |