Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/datawookie/ether

An R package for working with Ethereum
https://github.com/datawookie/ether

Last synced: 3 months ago
JSON representation

An R package for working with Ethereum

Awesome Lists containing this project

README

        

---
output: github_document
self_contained: false
---

```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
source("setup-key-for-test.R")
```

# ether

[![Travis-CI Build Status](https://travis-ci.org/datawookie/ether.svg?branch=master)](https://travis-ci.org/datawookie/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](https://github.com/ethereum/wiki/wiki/JSON-RPC) on the Ethereum Wiki.

## Installation

Install from GitHub using

```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("datawookie/ether")
```

Alternatively there is a stable version listed on CRAN.

## Example

Load the package.

```{r}
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](https://infura.io/). Assuming that you have created an infura.io API key and stored it in the `INFURA_MAINNET_KEY` environment variable.

```{r}
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.

```{r}
eth_blockNumber()
```
```{r}
eth_gasPrice()
```

```{r}
eth_getBalance("0xD34DA389374CAAD1A048FBDC4569AAE33fD5a375")
```

```{r}
eth_getTransactionCount("0xD34DA389374CAAD1A048FBDC4569AAE33fD5a375")
```