Library / SDK
tronprotocol/tronweb avatar
tronprotocol/tronweb

TronWeb wraps the TRON HTTP API in a TypeScript SDK

Javascript API Library for interacting with the TRON Network

572 stars389 forksTypeScriptMIT

At a glance

What is it?
TronWeb is the JavaScript and TypeScript client library for the TRON network, reworked as a full TypeScript rewrite for the 6.x line. It is easy to adopt for Node and browser work, but the v5 to v6 constructor change and the API key header it expects will cost you a migration.
Who is it for?
Adopt TronWeb for browser dapps, Node.js services and IoT clients that need typed access to TRON HTTP endpoints, and treat the 6.x migration as a scheduled piece of work rather than an in-place dependency bump. Do not adopt it if you cannot accept a client that expects node URLs, API key headers and a private key in configuration, or if you need a library that signs transactions without ever holding a key in application memory.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 37 days ago.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

A client for TRON nodes, not a wallet

TronWeb is a JavaScript API library for talking to the TRON network, and the package manifest describes it as a JavaScript SDK that encapsulates the TRON HTTP API. That distinction matters. The library is a convenience and consistency layer over an HTTP interface that a node already exposes, not a node implementation, not a consensus client and not a key management system. The README puts the audience in front-end dapps, Node.js services and IoT devices, and the compatibility section states the build targets: a version for Node.js v14 and above, and a version for browsers with more than 0.25% market share, with both available separately from the dist folder. The scope section is unusually clear for a client library, since it commits the project to incorporating new TRON features and to API changes that improve quality of life, while saying nothing about running infrastructure. If you are evaluating it as a dependency rather than as a system, that is the whole contract: you get a typed, packaged way to call node endpoints.

fullNode, solidityNode and eventServer are three separate servers

The design decision that shapes everything else in TronWeb is that the three kinds of TRON endpoint are configured independently. A fullNode serves general chain queries and transaction submission, a solidityNode serves the solidity compiled side of the chain, and an eventServer serves contract event logs. The README describes a fullHost option as a convenience that fills all three at once, with the more precise values taking priority when both are supplied. The constructor also takes a privateKey, so the library can sign and broadcast without a separate signer. For an application pointed at a single provider that serves everything, the object form is one field. For an application that separates event querying from chain reads, or that pins a solidity node for correctness, the object form is three or four fields plus a key, and the ordering of precedence matters when you set several. A legacy form is still accepted, where the four values are passed positionally, which is the shortest path to a working v5 style setup but also the form most likely to break silently after an upgrade, since the argument list and the object are not interchangeable.

npm install tronweb and dropping the dist bundle into a page

Installation is the usual two commands, and the project is published to npm:

bash
npm install tronweb
bash
yarn add tronweb

For a browser without a bundler, the README describes a manual route: install the package, then copy the prebuilt file out of node_modules into the working folder.

bash
cp node_modules/tronweb/dist/TronWeb.js ./js/tronweb.js

After that the page includes the copy with a script tag:

html
<script src="./js/tronweb.js"></script>

The README notes that the project is also on npm with CDN mirrors of the release, and it asks you to use sub-resource integrity for any script include, which is a good default to follow since a dapp bundle holds signing material. The manual copy route does mean you own the update cadence of that file, since the version in node_modules and the version served to browsers drift apart unless you automate the copy. The README also states that TronWeb works with Angular, React and Vue, and that it can be shipped inside a Chrome extension, so the plain script tag is the fallback rather than the recommended path for most teams.

A private chain from a single Docker command

For anything heavier than a testnet, the README points at the TRON Runtime Environment, described as a Docker based local blockchain runtime that provides a full TRON network for development, testing and automation. The setup needs Docker installed, and then one command:

bash
docker run -it -p 9090:9090 --rm --name tron tronbox/tre:dev

Once the container is up, the local node is reachable at http://localhost:9090, which is the endpoint you hand to TronWeb as fullHost, solidityNode or eventServer depending on what the local runtime serves. The contribution flow in the README assumes this setup, since the instructions list running a local private network between building the dist files and running the tests. That ordering is the useful part for your own CI: a build, then a chain, then a test run against a chain you control, rather than against a shared public endpoint. The public option remains available too. The README names Nile as a TRON testnet with the endpoint https://nile.trongrid.io, points at nileex.io for test TRX, and notes that everything you do there is explorable on nile.tronscan.org, which is a reasonable way to see what your transactions actually did.

The 6.x rewrite changed the constructor and the imports

The whole library was rewritten in TypeScript, and the README is direct about the consequence: there are breaking changes, and the 6.x API documentation holds the details. The visible surface of the change is in the import statement, where the entry point now exports the client, a utils namespace, a transaction type, TransactionBuilder, Contract, Event and Plugin:

typescript
import { TronWeb, utils as TronWebUtils, Trx, TransactionBuilder, Contract, Event, Plugin } from 'tronweb';

The README also warns explicitly that this is not the same as v5.x and links a migration guide. The old positional constructor still appears in the documentation, so the two styles coexist in the docs but not necessarily in the same application, and the safe assumption when upgrading is that a v5 code base needs a deliberate pass rather than a version bump. The build system reflects the rewrite. The manifest carries separate TypeScript projects for ESM, CommonJS and type output, and a webpack configuration for the browser bundle, with a build:all script that chains the clean, the ESM build, the CommonJS build and the dist build:

json
        "build:all": "npm run clean:all && npm run build:esm && npm run build:cjs && npm run build:dist",
        "test": "vitest run",

Tests run under vitest, with a separate browser configuration file, and the coverage and watch scripts are there too. A TypeScript consumer therefore gets an ESM entry, a CommonJS entry and separate type definitions for a utils subpath, all declared in the exports map.

The webpack .cjs rule bundlers need to resolve TronWeb

One failure mode is documented in enough detail to be worth quoting, because it is a symptom of the CommonJS build rather than of your own code. The symptom is a destructuring error on Transaction of globalThis.TronWebProto being undefined, and the README attributes it to webpack not loading the cjs file correctly. The fix is a new rule in the webpack config:

js
{
      test: /\.cjs$/,
      type: 'javascript/auto'
}

That is a small fix with a wide blast radius. It forces every .cjs file in your bundle to be treated as JavaScript rather than as a module type, which means the rule applies to your dependencies as well as to TronWeb. A team that ships several libraries with mixed module formats will want to scope the rule more tightly than the README does, and that is a decision the documentation leaves open. The other documented way to reach the same failure is to install TronWeb without a bundler and copy the dist file, which sidesteps module resolution entirely, at the price of giving up tree shaking and type checking on the browser side. A further note on the header: the client can be given a TRON-PRO-API-KEY header, and the README shows this being applied through a setHeader call on the instance, so an application using a hosted provider with key based access needs that header present on every request.

What TronWeb does not do for you

Three limits are worth stating before adoption. First, this is a client, so it is only as available as the node you point it at. There is no connection management, no retry policy and no failover described in the README, and if you rely on a single hosted provider then its availability and rate limits become your application's availability. The API key header exists for a reason. Second, the private key is a constructor argument in every documented form, which means it lives in the configuration of the process that runs your dapp or service. The README says nothing about hardware wallets, key derivation, encrypted key storage or rotating a compromised key, so if key custody is part of your requirements, this library covers the request signing part and leaves the custody problem entirely to you. Third, the 6.x line is a rewrite, and rewrites of libraries that other people's dapps depend on tend to move for a while. The project publishes a CHANGELOG with new features, dependency updates and bug fixes, and it states that every new TRON feature will be folded in, so expect the API surface to keep growing and expect another breaking change to be possible.

A wrapped SDK against signing raw HTTP calls yourself

The realistic alternative is not a different library but a different approach: skip the SDK, call the TRON HTTP API directly, and sign transactions with your own crypto code. The difference shows up in three places. Typed surface against hand written requests: the SDK gives you named methods, a TransactionBuilder, a Contract type and an Event type, so application code reads as intent rather than as request assembly, while the raw approach means you construct and sign every payload yourself. Configuration against hardcoded endpoints: TronWeb's constructor takes the node URLs and the key, so swapping providers is a configuration change, while the raw approach has endpoint URLs scattered through your code unless you build the same layer yourself, which is the work the SDK already did. Onboarding against key custody: the SDK takes a private key as a parameter, so you decide where it comes from, while the raw approach leaves you the same choice but with no help. The SDK wins on time to first transaction and on a uniform API across the browser and Node targets. The raw approach wins on control, on bundle size, and on the ability to sign with hardware or a remote signer that the library knows nothing about.

MIT licence, signed packages, and releases every few weeks

TronWeb is distributed under an MIT licence, which is the permissive end of the spectrum and suits commercial use in a product, with the usual requirement that the copyright notice and licence text travel with copies and substantial portions of the code. The project also describes an integrity check: package files are signed with a GPG key pair, and the README prints the public key fingerprint to verify the signature against, with the uid [email protected]. That gives you a way to confirm a downloaded artefact matches what the maintainers signed, which matters more than usual for a library that ends up holding a private key in application memory. On maintenance, the repository is not archived and the last push was on 2026-09-16, the same day as release v6.5.1, with v6.5.0 on 2026-08-20 and v6.4.0 on 2026-06-29 before it. The CHANGELOG is the place to look for what changed, and it covers new features, dependency updates and bug fixes. The upgrade cost for a consumer is therefore a version bump, a run of the test suite and attention to the changelog, and the risk sits in the 6.x breaking changes rather than in the pace of releases.

Editorial conclusion

Adopt TronWeb for browser dapps, Node.js services and IoT clients that need typed access to TRON HTTP endpoints, and treat the 6.x migration as a scheduled piece of work rather than an in-place dependency bump. Do not adopt it if you cannot accept a client that expects node URLs, API key headers and a private key in configuration, or if you need a library that signs transactions without ever holding a key in application memory. Verify three things before you commit: that the constructor style you already use survives the move to the object form, which dist bundle your bundler resolves for a browser build, and what the hosting provider's key header costs you in requests, then pin the exact version your tests passed against.

Frequently asked questions

How do I install TronWeb in a Node.js project?

The README gives npm install tronweb, with yarn add tronweb as an alternative, and states that the build targets Node.js v14 and above. The package publishes both a CommonJS and an ESM entry point.

What is the difference between fullHost, fullNode, solidityNode and eventServer in TronWeb?

The README describes fullHost as a convenience that fills every slot at once, while the more precise values take priority when both are given. fullNode, solidityNode and eventServer each point at a server for that role, and a privateKey can be supplied as well.

Is TronWeb 6.x compatible with my v5 code?

No. The README says the library was rewritten in TypeScript and that there are breaking changes, and it points to the 6.x API documentation and a migration guide from v5. The old positional constructor form is still shown in the documentation.

How do I run a local TRON network for testing with TronWeb?

The README describes the Docker based TRON Runtime Environment, and the command docker run -it -p 9090:9090 --rm --name tron tronbox/tre:dev starts it. The local node is then available at http://localhost:9090. A public alternative is the Nile testnet at https://nile.trongrid.io.

What licence is TronWeb released under and how are packages signed?

The README states that TronWeb is distributed under an MIT licence. It also describes an integrity check in which package files are signed with a GPG key pair, with the public key fingerprint printed in the README for verification.

Official sources

  1. Issues
  2. License: MIT
  3. README
  4. Releases
  5. tronprotocol/tronweb on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/tronprotocol-tronweb.svg)](https://hysenlabs.com/projects/tronprotocol-tronweb)

Was this useful?