https://github.com/next-game-solutions/tronr
R toolbox to explore the TRON blockchain
https://github.com/next-game-solutions/tronr
coingecko-api crypto cryptocurrency r trc-10 trc-20 tron tron-api trongrid tronix tronscan
Last synced: 7 months ago
JSON representation
R toolbox to explore the TRON blockchain
- Host: GitHub
- URL: https://github.com/next-game-solutions/tronr
- Owner: next-game-solutions
- License: other
- Created: 2020-10-20T20:48:08.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-18T13:53:48.000Z (almost 5 years ago)
- Last Synced: 2025-06-28T09:28:19.250Z (11 months ago)
- Topics: coingecko-api, crypto, cryptocurrency, r, trc-10, trc-20, tron, tron-api, trongrid, tronix, tronscan
- Language: JavaScript
- Homepage: https://next-game-solutions.github.io/tronr/
- Size: 1.7 MB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
[](https://github.com/next-game-solutions/tronr/actions/workflows/r.yml)
[](https://codecov.io/gh/next-game-solutions/tronr)
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
`tronr` is a toolbox to explore the [TRON blockchain](https://tron.network/index?lng=en). This R package allows one to collect data on the blockchain’s accounts, transactions, token transfers, and smart contract events. In addition, users can query the current and historical market status of [Tronix (TRX)](https://tron.network/trx?lng=en), the native currency of TRON.
## Installation
At the moment, `tronr` is only available on GitHub and can be installed with:
``` r
# install.packages("devtools")
devtools::install_github("next-game-solutions/tronr")
```
A [CRAN](https://cran.r-project.org/) version of the package is planned for release in the near future.
## Examples
Detailed examples of how to use `tronr` can be found in its [online documentation](https://next-game-solutions.github.io/tronr/). Provided below are just a few common queries:
```{r example, message=FALSE, fig.align='center', fig.width=10, fig.height=4.5}
library(tronr)
library(dplyr)
library(ggplot2)
# Current price of TRX expressed in USD, EUR and BTC (Bitcoin):
get_current_trx_price(vs_currencies = c("usd", "eur", "btc"))
# Querying the TRX market data for a historical period, and plotting the
# evolution of price:
(min_timestamp <- as.POSIXct("2020-01-01 00:00:00") %>% to_unix_timestamp())
(max_timestamp = as.POSIXct("2020-05-01 00:00:00") %>% to_unix_timestamp())
price_history <- get_trx_market_data_for_time_range(
vs_currency = "usd",
min_timestamp = min_timestamp,
max_timestamp = max_timestamp
)
glimpse(price_history)
price_history %>%
ggplot(aes(timestamp, price)) +
geom_line() +
theme_minimal()
# Information on the latest block on the chain:
get_block_info(latest = TRUE) %>%
glimpse()
# Current balance of an account:
get_account_balance("TQjaZ9FD473QBTdUzMLmSyoGB6Yz1CGpux") %>%
glimpse()
# TRC-10 asset transfers to / from an account within a time range:
get_trc10_transfers(
related_address = "TMaBqmMRekKZMQEq3u3QrJpGDwPYZZo87V",
min_timestamp = "1577837400000",
max_timestamp = "1577837430000"
) %>% glimpse()
```
## Things to keep in mind when using `tronr`
The design of this package is rather opinionated, which among other aspects means the following:
1. Under the hood, most of the transaction-related data are queried in `tronr` via a public API that powers the [Tronscan website](https://tronscan.org/). This has a few important implications:
- The [Tronscan API](https://github.com/tronscan/tronscan-frontend/blob/master/document/api.md "Tronscan API") is considerably slower than the [TronGrid API](https://www.trongrid.io/), which is the recommended tool for use cases that require a computationally efficient and robust mechanism to extract large amounts of data from the TRON blockchain. However, the Tronscan API was chosen due to the richer and more schema-consistent data it returns. As the TronGrid API matures, the decision on using the Tronscan API in `tronr` may be re-considered.
- Attempts to perform frequent and/or "heavy" queries from the same IP address using `tronr` may be treated by the Tronscan servers as [denial-of-service attacks](https://www.cloudflare.com/en-gb/learning/ddos/glossary/denial-of-service/) and lead to black-listing of that IP address. Users of `tronr` are thus kindly asked to be considerate and implement the respective safeguards in their code (e.g., breaking the queries into smaller chunks, with pauses in between).
- As a result of the previous two points, `tronr` is _not_ intended for the development of high-load analytical applications.
2. Many of the `tronr` functions return data in the form of [nested tibbles](https://tidyr.tidyverse.org/articles/nest.html) (see examples above). Arguably, this is a natural choice for such data, given their hierarchical structure. Nested tibbles were chosen also because they represent a “tidy” data format compatible with the [`tidyverse`](https://www.tidyverse.org/ "tidyverse") toolkit (in particular, the [`tidyr`](https://tidyr.tidyverse.org/ "tidyr") package). Admittedly, though, not all R users prefer working with the `tidyverse` tools and this makes `tronr` somewhat less accessible and attractive for such users.
## Getting help
If you encounter a clear bug, please file an issue with a minimal reproducible example on [GitHub](https://github.com/next-game-solutions/tronr/issues).
## License
This package is licensed to you under the terms of the MIT License.
The TRON logo ("red diamond") used in the `tronr` hexagon sticker is property of the [TRON Foundation](https://tron.network/). It originates from the official icon pack, which is available for download and free use at the Foundation's website.
Copyright (c) `r substr(as.Date(Sys.Date()), 1, 4)` [Next Game Solutions OÜ](http://nextgamesolutions.com)
---
Please note that this project is released with a [Contributor Code of Conduct](https://www.contributor-covenant.org/version/1/0/0/code-of-conduct/). By participating in this project you agree to abide by its terms.
