-
Notifications
You must be signed in to change notification settings - Fork 12
/
README.Rmd
65 lines (46 loc) · 1.7 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
output: github_document
self_contained: false
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{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")
```