Skip to main content

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-hypernode.com/pypi/ethereum-rpc-client) [![PyPi downloads](https://pypip.in/d/ethereum-rpc-client/badge.png)](https://pypi-hypernode.com/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 ethereum_rpc_client import Client >>> client = Client(host="127.0.0.1", port="8454") >>> 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ethereum-rpc-client-0.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distributions

ethereum_rpc_client-0.1.0-py2-none-any.whl (5.7 kB view details)

Uploaded Python 2

File details

Details for the file ethereum-rpc-client-0.1.0.tar.gz.

File metadata

File hashes

Hashes for ethereum-rpc-client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1614bd5dedee7edd922f155fd2422697a989e227b43be3c3f56271b3f007f159
MD5 9282e0dd58869ad5881918fa49494ea8
BLAKE2b-256 7d5f6a510297ac61db38790277276d26f9da385daf26dff3ef4b3269c5833975

See more details on using hashes here.

File details

Details for the file ethereum_rpc_client-0.1.0-py2-none-any.whl.

File metadata

File hashes

Hashes for ethereum_rpc_client-0.1.0-py2-none-any.whl
Algorithm Hash digest
SHA256 9e04a3568825152be513eb5e41de2856c4f370c514d4cbed0e85deabc8b03127
MD5 e5b528ff836380db08442e95a1b67462
BLAKE2b-256 18c3d412a8a32121cf21d19b167f91f5a99f208d986551125b381dfd27bb1891

See more details on using hashes here.

File details

Details for the file ethereum-rpc-client-0.1.0.macosx-10.10-x86_64.tar.gz.

File metadata

File hashes

Hashes for ethereum-rpc-client-0.1.0.macosx-10.10-x86_64.tar.gz
Algorithm Hash digest
SHA256 8c9f21972dbdaad4678d4aaac977751243331bced1f2ef985786846946082101
MD5 deb3c965d1ed593034194d07f4aa7c00
BLAKE2b-256 c66f54a4efce4823f65a91950132014ec3165f39f005def8601933e8743cc95a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page