Learn R Programming

ether

The ether package provides functions for interacting with the Ethereum network.

The details of the RPC interface along with curl examples of interacting with it are documented in the JSON RPC page on the Ethereum Wiki.

Installation

Install from GitHub using

# install.packages("devtools")
devtools::install_github("DataWookie/ether")

Alternatively there is a stable version listed on CRAN.

Example

Load the package.

library(ether)

You'll need to connect to an Ethereum node exposing a RPC interface. By default the package will attempt to connect to a node on localhost using port 8545. However, you can also make use of the public RPC nodes hosted by infura.io. Assuming that you have created an infura.io API key and stored it in the INFURA_MAINNET_KEY environment variable.

set_rpc_address("https://mainnet.infura.io/", key = Sys.getenv("INFURA_MAINNET_KEY"))

Once you've configured the connection to RPC you are ready to interact with the Ethereum blockchain.

eth_blockNumber()
#> [1] 4867006
eth_gasPrice()
#> 1 'mpfr' number of precision  40   bits 
#> [1] 100000000000
eth_getBalance("0xD34DA389374CAAD1A048FBDC4569AAE33fD5a375")
#> 1 'mpfr' number of precision  60   bits 
#> [1] 194274248530503149
eth_getTransactionCount("0xD34DA389374CAAD1A048FBDC4569AAE33fD5a375")
#> [1] 1150417

Copy Link

Version

Install

install.packages('ether')

Monthly Downloads

31

Version

0.1.6

License

GPL-2

Maintainer

Andrew Collier

Last Published

January 25th, 2020

Functions in ether (0.1.6)

dec_to_hex

Convert decimal to hexadecimal.
eth_getBlockTransactionCountByHash

Returns the number of transactions in a block matching the given block hash.
eth_getTransactionReceipt

Returns the receipt of a transaction by transaction hash.
eth_getUncleByBlockHashAndIndex

Returns information about an uncle of a block by hash and uncle index position.
as.mwei

Convert Wei to MWei.
get_blocks

Retrieve a series of blocks.
get_post_response

Submit POST to Ethereum RPC.
eth_blockNumber

Returns the number of most recent block.
eth_getUncleCountByBlockNumber

Returns the number of uncles in a block from a block matching the given block number.
eth_gasPrice

Returns the current gas price in wei.
eth_hashrate

Returns the number of hashes per second that the node is mining with.
eth_coinbase

Returns the client coinbase address.
eth_getBalance

Returns the balance (in Wei) of the account at specified address.
hex_to_dec

Convert hexadecimal to decimal.
set_rpc_address

Set address used for RPC.
as.ether

Convert Wei to Ether.
as.finney

Convert Wei to Finney.
eth_getTransactionByHash

Returns the information about a transaction.
eth_getBlockTransactionCountByNumber

Returns the number of transactions in a specified block.
eth_getStorageAt

Returns the value from a storage position at a given address.
as.gwei

Convert Wei to GWei.
as.kwei

Convert Wei to kWei.
eth_mining

Returns true if client is actively mining new blocks.
as.szabo

Convert Wei to Szabo.
eth_getTransactionCount

Returns the number of transactions sent from an address.
eth_getTransactionByBlockHashAndIndex

Returns information about a transaction by block hash and transaction index position.
eth_getTransactionByBlockNumberAndIndex

Returns information about a transaction by block number and transaction index position.
eth_syncing

Returns an object with data about the sync status.
eth_getUncleByBlockNumberAndIndex

Returns information about a uncle of a block by number and uncle index position.
web3_clientVersion

Returns the current client version.
web3_sha3

Returns Keccak-256 (not the standardized SHA3-256) of the given data.
eth_protocolVersion

Returns the current ethereum protocol version.
ether

ether: An R package for working with Ethereum.
eth_getUncleCountByBlockHash

Returns the number of uncles in a block from a block matching the given block hash.
get_transactions

Retrieve transactions for a series of blocks.
get_rpc_address

Get address used for RPC.
eth_getBlock

Returns information about a specified block.
eth_accounts

Returns addresses owned by client.