TRON Developer Hub

The TRON Developer Hub

Welcome to the TRON developer hub. You'll find comprehensive guides and documentation to help you start working with TRON as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Tron-Web Class

Tron-Web Object

Creates an instance of the Tron-Web javascript library. This encapsulates all related modules in addition to utility functions.

const TronWeb = require('tronweb');
const HttpProvider = TronWeb.providers.HttpProvider;

const fullNode = new HttpProvider('https://api.trongrid.io');
const solidityNode = new HttpProvider('https://api.trongrid.io');
const eventServer = 'https://api.trongrid.io/';
const privateKey = 'da14...9f0d0';

const tronWeb = new TronWeb(
    fullNode,
    solidityNode,
    eventServer,
    privateKey
);

Set Default Block

tronWeb.setDefaultBlock('latest');

Sets the default block used as a reference for all future calls.

Value
Description

Block

Block Height or ID

Set Address

tronWeb.setAddress('TVJ6njG5EpUwJt4N9xjTrqU5za78cgadS2');

Sets the address used with all Tron-Web API's. Does not sign any transactions.

Value
Description

Address

Address of account.

Get Event Result

tronWeb.getEventResult("TVJ6njG5EpUwJt4N9xjTrqU5za78cgadS2", "BUY");

Returns all events.

Value
Description

Contract Address

Address of contract.

Contract Name

Name of contract.

Set Private Key

Warning: Do not use this with any web/user facing Tron-Web instances. This leaks the private key.

tronWeb.setPrivateKey('da146...f0d0');

Set a private key used with the TronWeb instance, used for obtaining the address, signing transactions, and getting balances.

Value
Description

Private Key

Private key of account.