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 = new TronWeb({
    fullNode: 'https://api.trongrid.io',
    solidityNode: 'https://api/somesolidity.io',
    eventServer: 'https://api.somevent.io'
  }, 
  privateKey
)

Set Default Block

tronWeb.setDefaultBlock('latest');

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

ValueDescription
BlockBlock Height or ID

Set Address

tronWeb.setAddress('TVJ6njG5EpUwJt4N9xjTrqU5za78cgadS2');

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

ValueDescription
AddressAddress of account.

Get Event Result

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

Returns all events.

ValueDescription
Contract AddressAddress of contract.
Contract NameName 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.

ValueDescription
Private KeyPrivate key of account.