Ethereum JSON RPC Client
Project description
# Ethereum RPC Client
[![Build Status](https://travis-ci.org/pipermerriam/ethereum-rpc-client.png)](https://travis-ci.org/pipermerriam/ethereum-rpc-client) [![Documentation Status](https://readthedocs.org/projects/ethereum-rpc-client/badge/?version=latest)](https://readthedocs.org/projects/ethereum-rpc-client/?badge=latest) [![PyPi version](https://pypip.in/v/ethereum-rpc-client/badge.png)](https://pypi.python.org/pypi/ethereum-rpc-client) [![PyPi downloads](https://pypip.in/d/ethereum-rpc-client/badge.png)](https://pypi.python.org/pypi/ethereum-rpc-client)
Python client for Ethereum JSON RPC Server
> Note that this currently only implements a handful of the JSON RPC methods > exposed by the server.
## Installation
Install with pip
`bash $ pip install ethereum-rpc-client `
## Basic Usage
Assuming you have an Ethereum node running the JSON RPC server on localhost:8454
`python >>> from eth_rpc_client import Client >>> client = Client(host="127.0.0.1", port="8545") >>> client.get_coinbase() ... '0xd3cda913deb6f67967b99d67acdfa1712c293601' `
## API
### Client.get_coinbase()
> https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_coinbase
Returns the hex encoded coinbase.
### Client.get_gas_price()
> https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gasprice
Returns the gas price in wei as an integer
### Client.get_balance(address, block=”latest”)
> https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getbalance
address: The hex encoded address to lookup the balance for.
block: The block to use for the lookup.
Returns the account balance for the address in wei as an integer.
### Client.get_code(address, block=”latest”)
> https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getcode
address: The hex encoded address to lookup the code for.
block: The block to use for the lookup.
Returns the code at the given address.
### Client.call(_from=None, to=None, gas=None, gas_price=None, value=0, data=None, block=”latest”)
> https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_call
_from: The hex encoded address to use as the source for the call.
to: The hex encoded address of the contract for the call.
gas: Integer gas alotment for the call.
gas_price: Integer gas price in wei.
value: Integer amount in wei to send with the call.
data: The call data.
Returns the call response.
### Client.get_transaction_receipt(txn_hash)
> https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionreceipt
txn_hash: The hex encoded transaction hash to lookup.
Returns a dictionary of the transaction receipt or None if no receipt is found.
transactionHash: hex encoded hash of the transaction.
transactionIndex: integer of the transactions index position in the block.
blockHash: hex encoded hash of the block where this transaction was in.
blockNumber: integer block number where this transaction was in.
cumulativeGasUsed: The total amount of gas used when this transaction was executed in the block.
gasUsed: The amount of gas used by this specific transaction alone.
contractAddress: The contract address created, if the transaction was a contract creation, otherwise null.
logs: list of log objects, which this transaction generated
### Client.get_transaction_by_hash(txn_hash)
> https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyhash
txn_hash: The hex encoded transaction hash to lookup.
Returns a dictionary of the transaction values or None if no transaction is found.
hash: DATA, 32 Bytes - hash of the transaction.
nonce: QUANTITY - the number of transactions made by the sender prior to this one.
blockHash: DATA, 32 Bytes - hash of the block where this transaction was in. null when its pending.
blockNumber: QUANTITY - block number where this transaction was in. null when its pending.
transactionIndex: QUANTITY - integer of the transactions index position in the block. null when its pending.
from: DATA, 20 Bytes - address of the sender.
to: DATA, 20 Bytes - address of the receiver. null when its a contract creation transaction.
value: QUANTITY - value transferred in Wei.
gasPrice: QUANTITY - gas price provided by the sender in Wei.
gas: QUANTITY - gas provided by the sender.
input: DATA - the data send along with the transaction.
### Client.get_block_number()
> https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_blocknumber
Returns the number of the most recent block.
### Client.get_accounts()
> https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_accounts
Returns a list of the addresses owned by the client.
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
Built Distributions
Hashes for ethereum-rpc-client-0.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c96f7249cde647060e75f7ef2a6f9bb796d5770806eea9695b69922890856c4 |
|
MD5 | dd2c95d5e8a0a42a7cac124ec0a05318 |
|
BLAKE2b-256 | 6682b68ea0924c13876885bd270137f1f25fd6f218b3141c7c8eb288e9a87f39 |
Hashes for ethereum_rpc_client-0.3.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4f1d05406e0b1a591dfd1124d165839e89dfc7a0f6434b4b1784d8e0f084647 |
|
MD5 | 734634e1eb208dc42dbb9aa0b58e967c |
|
BLAKE2b-256 | 4077e903dfc3006336a2380ebed0946f3ae64ba962ce076fa65a67f32440b181 |
Hashes for ethereum-rpc-client-0.3.0.macosx-10.10-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1961dfd448918e300dce5c251b44ab53e0932c90f597debbe39c0474a6c197ec |
|
MD5 | 347b3fbf905b009b088d50adb8f6837f |
|
BLAKE2b-256 | 86d3584318e0531760e145b21b221ed1fb97a86d27b9235a8009883bdf720950 |