Blockchain transactions that involve transfer of assets from one account to another are often of particular interest. One way to detect such transactions on the TRON blockchain is to apply get_tx_by_account_address()
or get_tx_for_time_range()
and then filter the returned results by the field contract_type
(e.g., looking for the values such as TransferContract
or TransferAssetContract
). However, tronr
also offers two dedicated functions to query the TRC-10 and TRC-20 token transfers: get_trc10_transfers()
and get_trc20_transfers()
.
The two functions have almost identical arguments. In particular, users can specify the time range of interest with the min_timestamp
and max_timestamp
arguments. If no other parameters are provided, both functions will return all transfers of the respective tokens that took place within that time range:
library(tronr)
# Results contain all TRC-10 transfers that took place
# within the specified time range:
get_trc10_transfers(
min_timestamp = "1577837400000",
max_timestamp = "1577837430000"
)
#> # A tibble: 15 x 13
#> tx_id block_number timestamp from_address to_address
#> <chr> <chr> <dttm> <chr> <chr>
#> 1 f641ef9c3b993… 15860789 2020-01-01 00:10:30 TAGY4jZiHLF7Jn… THoVwtGGxwu6…
#> 2 cc71ee8a451b1… 15860788 2020-01-01 00:10:27 TEEqgcJFNYJd6X… TP6d1u2aEhW9…
#> 3 604a65a85f794… 15860788 2020-01-01 00:10:27 TGV7WvYAZdoLtX… TQaiSLgGYj3n…
#> 4 d6c59b6d73b7a… 15860788 2020-01-01 00:10:27 TNk53vo7ihZobd… TLvQcFbrvxgD…
#> 5 675a3606a414f… 15860788 2020-01-01 00:10:27 TMaBqmMRekKZMQ… TT5W8MPbYJih…
#> 6 0d38557f1495d… 15860787 2020-01-01 00:10:24 TZBDHDwQocwpWX… TLc41pwt3HJt…
#> 7 97a227a430ab1… 15860787 2020-01-01 00:10:24 TV5jzbbiBhp2UT… TFfayfUQpfFW…
#> 8 5e6025a703032… 15860786 2020-01-01 00:10:21 TDsxwH2QimMFpq… TJKWvFZVTX3k…
#> 9 4081eb369aa2c… 15860784 2020-01-01 00:10:15 TQoX5EnSpaBAZL… TFCn5JuJ4fCd…
#> 10 ae2000ea3e10b… 15860784 2020-01-01 00:10:15 TMaBqmMRekKZMQ… TBhjJyuXnadz…
#> 11 cda3b9f5a59f6… 15860783 2020-01-01 00:10:12 TXYLN4bQZe1j7A… TXXsngWoLCtE…
#> 12 d1210b09f7ae0… 15860783 2020-01-01 00:10:12 TNk53vo7ihZobd… TJLzg1dBAjaP…
#> 13 0ae49511eca29… 15860783 2020-01-01 00:10:12 TMJMkYike39YNU… TFTAC3k9KFQA…
#> 14 8340fe21bcd12… 15860782 2020-01-01 00:10:09 TNLTMTwWQX2T24… TMhM9YmRXN8t…
#> 15 d4df90e8fe8d0… 15860780 2020-01-01 00:10:03 TQ7WucGRWyzW9T… TGwpHfMKcj9G…
#> # … with 8 more variables: is_contract_from_address <lgl>,
#> # is_contract_to_address <lgl>, contract_result <chr>, confirmed <lgl>,
#> # amount <dbl>, token_id <chr>, token_name <chr>, token_abbr <chr>
# Results contain all TRC-20 transfers that took place
# within the requested time range:
get_trc20_transfers(
min_timestamp = "1609459860000",
max_timestamp = "1609459865000"
)
#> # A tibble: 7 x 13
#> tx_id block_number timestamp from_address to_address
#> <chr> <chr> <dttm> <chr> <chr>
#> 1 ce343811d4d2f… 26368083 2021-01-01 00:11:03 TVn1pGmuZRfUPYB… TFQyXjQXUuBC…
#> 2 db14cb7057821… 26368083 2021-01-01 00:11:03 TNaRAoLUyYEV2uF… TNuXJj7NvA3e…
#> 3 6c96ed38b8162… 26368083 2021-01-01 00:11:03 TYci9vinp8PByaE… TMpkzcmPb1BW…
#> 4 75d785972605a… 26368083 2021-01-01 00:11:03 TNaRAoLUyYEV2uF… TP9sBpao6VQW…
#> 5 8739d87ed1e4c… 26368083 2021-01-01 00:11:03 TDfKAoGTgQsHCoA… TEJPcb6ULVnz…
#> 6 56e665ef5143d… 26368083 2021-01-01 00:11:03 TS3cGyL3DvpMo15… TSH9XuuiYDF8…
#> 7 4ce68f65055f4… 26368083 2021-01-01 00:11:03 TEPSrSYPDSQ7yXp… TFknPRnUr4PX…
#> # … with 8 more variables: is_contract_from_address <lgl>,
#> # is_contract_to_address <lgl>, contract_result <chr>, confirmed <lgl>,
#> # amount <dbl>, token_contract_address <chr>, token_name <chr>,
#> # token_abbr <chr>
To retrieve transfers of a specific TRC-10 token, one can supply the owner_address
argument to the get_trc10_transfers()
function. As the name suggests, this argument expects the token creator’s address. If unknown, this address can be found using the function get_trc10_token_description()
or from the Tronscan website.
# Results contain transfers of a specific TRC-10 token:
get_trc10_transfers(
owner_address = "TF5Bn4cJCT6GVeUgyCN4rBhDg42KBrpAjg",
min_timestamp = "1577837400000",
max_timestamp = "1577837430000"
)
#> # A tibble: 1 x 13
#> tx_id block_number timestamp from_address to_address
#> <chr> <chr> <dttm> <chr> <chr>
#> 1 97a227a430ab1… 15860787 2020-01-01 00:10:24 TV5jzbbiBhp2UTK… TFfayfUQpfFW…
#> # … with 8 more variables: is_contract_from_address <lgl>,
#> # is_contract_to_address <lgl>, contract_result <chr>, confirmed <lgl>,
#> # amount <dbl>, token_id <chr>, token_name <chr>, token_abbr <chr>
In case with the TRC-20 tokens, one would need to supply the contract_address
argument instead, that is the address of the token’s smart contract:
# Results contain transfers of a specific TRC-20 token:
get_trc20_transfers(
contract_address = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
min_timestamp = "1609459860000",
max_timestamp = "1609459865000"
)
#> # A tibble: 8 x 13
#> tx_id block_number timestamp from_address to_address
#> <chr> <chr> <dttm> <chr> <chr>
#> 1 ce343811d4d2f… 26368083 2021-01-01 00:11:03 TVn1pGmuZRfUPYB… TFQyXjQXUuBC…
#> 2 db14cb7057821… 26368083 2021-01-01 00:11:03 TNaRAoLUyYEV2uF… TNuXJj7NvA3e…
#> 3 6c96ed38b8162… 26368083 2021-01-01 00:11:03 TYci9vinp8PByaE… TMpkzcmPb1BW…
#> 4 75d785972605a… 26368083 2021-01-01 00:11:03 TNaRAoLUyYEV2uF… TP9sBpao6VQW…
#> 5 4ce68f65055f4… 26368083 2021-01-01 00:11:03 TEPSrSYPDSQ7yXp… TFknPRnUr4PX…
#> 6 f84de31808595… 26368082 2021-01-01 00:11:00 TMSxsUxYiNH2jJY… TNrU4UJP647U…
#> 7 f84de31808595… 26368082 2021-01-01 00:11:00 TNrU4UJP647UKgc… TQn9Y2khEsLJ…
#> 8 4dd19a5f22923… 26368082 2021-01-01 00:11:00 TQn9Y2khEsLJW1C… TVCkFCdTMSFv…
#> # … with 8 more variables: is_contract_from_address <lgl>,
#> # is_contract_to_address <lgl>, contract_result <chr>, confirmed <lgl>,
#> # amount <dbl>, token_contract_address <chr>, token_name <chr>,
#> # token_abbr <chr>
Results returned in the last two examples could be made even more specific by providing the related_address
argument. This would allow one to retrieve transfers to / from that related address:
# Transfers of a specific TRC-10 token, related to
# a specific account:
get_trc10_transfers(
owner_address = "THLLMnsEKEci5e5dJHnW28QQU8AujGhSoK",
related_address = "TBhjJyuXnadzLX1s3yHFduZgpCeWEzda5u",
min_timestamp = "1577837400000",
max_timestamp = "1577837430000"
)
#> # A tibble: 1 x 13
#> tx_id block_number timestamp from_address to_address
#> <chr> <chr> <dttm> <chr> <chr>
#> 1 ae2000ea3e10b… 15860784 2020-01-01 00:10:15 TMaBqmMRekKZMQE… TBhjJyuXnadz…
#> # … with 8 more variables: is_contract_from_address <lgl>,
#> # is_contract_to_address <lgl>, contract_result <chr>, confirmed <lgl>,
#> # amount <dbl>, token_id <chr>, token_name <chr>, token_abbr <chr>
# Transfers of a specific TRC-20 token, related to
# a specific account:
get_trc20_transfers(
contract_address = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
related_address = "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE",
min_timestamp = "1609459860000",
max_timestamp = "1609459865000"
)
#> # A tibble: 2 x 13
#> tx_id block_number timestamp from_address to_address
#> <chr> <chr> <dttm> <chr> <chr>
#> 1 f84de31808595… 26368082 2021-01-01 00:11:00 TNrU4UJP647UKgc… TQn9Y2khEsLJ…
#> 2 4dd19a5f22923… 26368082 2021-01-01 00:11:00 TQn9Y2khEsLJW1C… TVCkFCdTMSFv…
#> # … with 8 more variables: is_contract_from_address <lgl>,
#> # is_contract_to_address <lgl>, contract_result <chr>, confirmed <lgl>,
#> # amount <dbl>, token_contract_address <chr>, token_name <chr>,
#> # token_abbr <chr>
Both get_trc10_transfers()
and get_trc20_transfers()
return tibbles, whose variables are described in the respective help files.
Please note: the number of transactions that take place on the TRON blockchain is very large, and thus users are advised to choose
min_timestamp
andmax_timestamp
wisely. If the requested time range is too large, the maximum number of transactions returned by the underlying Tronscan API will be capped at 10000, and the processing time may become prohibitively long. Chunking the time range of interest into smaller periods can help to avoid gaps in data in such cases. However, users would have to implement their own logic for that.