# Introduction

TronGridJS is a Javascript library for utilizing TronGrid APIs to retrieve blockchain data from the TRON network.

# Compatibility

  • Version built for Node.js v6 and above.

  • Version built for browsers with more than 0.25% market share.

TronGridJS is also compatible with front-end frameworks like:

  • Angular

  • React

  • Vue

TronGridJS can also be shipped in a Chrome extension.

# Installation

<a href="https://www.npmjs.com/package/trongrid" target="_blank">**TronGridJS - NPM Package**</a>

**NPM**



**Yarn**



# Build Steps

If you would like to download and build locally, please follow the below steps:



# Supported APIs

TronGridJS allows for easy access to the new v1 APIs provided by TronGrid. Since TronGridJS uses TronWeb as a dependency, you need to initialize TronGridJS with TronWeb as a constructor parameter:


DescriptionSubstitutes
Returns information about the account at `accountAddress`/wallet/getaccount
ParameterDescriptionValues
onlyConfirmedShows only the situation at latest confirmed block.True | False (Default False)

DescriptionSubstitutes
Returns all the transactions related to the account at `accountAddress`/walletextension/gettransactionfromthis /walletextension/gettransactiontothis
ParameterDescriptionValues
only_confirmedShows only confirmed.true | false (default false)
only_unconfirmedShows only unconfirmed.true | false (default false)
only_toOnly transaction to address.true | false (default false)
only_fromOnly transaction from address.true | false (default false)
limitThe requested number of transaction per page.Default 20. Max 200.
fingerprintThe fingerprint of the last transaction returned by the previous page.
order_bySorts the results of the query. Example: order_by=timestamp, desc
min_timestampThe minimum transaction timestamp.default 0
max_timestampThe maximum transaction timestamp.default now

DescriptionSubstitutes
Returns all the assets on the TRON platform.N/A
ParameterDescriptionValue
order_bySorts the results.Accepted fields: id name total_supply start_time end_time

DescriptionSubstitutes
Returns an asset identified by either the owner address or its own ID./wallet/getassetissuebyaccount /wallet/getassetissuebyid

DescriptionSubstitutes
Returns all the assets with name `assetName`/wallet/getassetissuelistbyname /wallet/getassetissuelist
ParameterDescriptionValue
limitThe requested number of assets per page.Default 20. Max 200.
fingerprintThe fingerprint of the last asset returned by the previous page. When there is a pagination, the minimum limit is set to 20.
order_bySorts the results of the query.Accepted fields: id name total_supply start_time end_time Example: order_by=start_time,desc (starts from the most recent ICO) order_by=id,asc (starts from the oldest)
only_confirmedShows only the situation at latest confirmed block.true | false (default: false)

DescriptionSubstitutes
Returns all the events of a specific block. The identifier can be either `latest` or a block number.N/A

DescriptionSubstitutes
Returns all the events emitted by a smart contract.N/A
ParameterDescriptionValue
only_confirmedShows only confirmed.
only_unconfirmedShows only unconfirmed.
event_nameThe name of the event.
block_numberThe block number for which the events are required.
min_timestampThe minimum block timestamp.
max_timestampThe maximum block timestamp.
order_bySorts the events.Accepted values: timestamp, asc timestamp, desc (Default)
limitFor pagination.Default 20 Max 200
fingerprintThe fingerprint of the last event retrieved in the page.

DescriptionSubstitutes
Returns all the events emitted in the transaction specified by `id`N/A

# Responses & Pagination

Any API will return a response with a success property, a data array, and a meta object. For example, `await tronGrid.asset.getAll()` will return something like:



As you can see, in the meta fields, there is the fingerprint you must pass to next request as an option in order to get next page.

# Usage

## Regular Use

Install TronWeb



Initialize TronWeb and create a TronGridJS instance



**Example**



## Plugin

You can plug TronGrid in TronWeb to substitute the standard method `tronWeb.trx.getTransactionRelated(...)` with a method that calls internally `tronGrid.account.getTransactions(...)`.

To use it, the user must register TronGrid as a plugin:



It may sometimes be necessary to pass some options to the plugin interface. Looking at the test in `test/unit/plugin.test.js`, you can register the plugin as:



For the MVP, the experimental access code can be passed as an option to the plugin:



After registering the plugin, call:



and



will return results from TronGrid under the hood.