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    

Integrating Blockchain APIs

Query via Transaction ID


Querying by Contract Events

You can query a contract for events and sort the results based on parameters passed in.

Case 1

Pass since or fromTimestamp


Case 2

Pass since or fromTimestamp & sort=-block_timestamp


Case 3

Pass since or fromTimestamp & sort=block_timestamp


Case 4

No Value Passed


Result: Returns all events starting with most recent on top of the page (descending order).

Example Contract

pragma solidity ^0.4.23;

contract Fibonacci {

    event Notify(uint input, uint result);

    function fibonacci(uint number) public constant returns(uint result) {
        if (number == 0) return 0;
        else if (number == 1) return 1;
        else return Fibonacci.fibonacci(number - 1) + Fibonacci.fibonacci(number - 2);

    function fibonacciNotify(uint number) public returns(uint result) {
        result = fibonacci(number);
        emit Notify(number, result);

Deploy contract using TronWeb, TronBox, or directly using RPC or HTTP call:

deploycontract DataStore [{"constant":false,"inputs":[{"name":"number","type":"uint256"}],"name":"fibonacciNotify","outputs":[{"name":"result","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"number","type":"uint256"}],"name":"fibonacci","outputs":[{"name":"result","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"input","type":"uint256"},{"indexed":false,"name":"result","type":"uint256"}],"name":"Notify","type":"event"}] 608060405234801561001057600080fd5b50610196806100206000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633c7fdc701461005157806361047ff414610092575b600080fd5b34801561005d57600080fd5b5061007c600480360381019080803590602001909291905050506100d3565b6040518082815260200191505060405180910390f35b34801561009e57600080fd5b506100bd60048036038101908080359060200190929190505050610124565b6040518082815260200191505060405180910390f35b60006100de82610124565b90507f71e71a8458267085d5ab16980fd5f114d2d37f232479c245d523ce8d23ca40ed8282604051808381526020018281526020019250505060405180910390a1919050565b6000808214156101375760009050610165565b60018214156101495760019050610165565b61015560028303610124565b61016160018403610124565b0190505b9190505600a165627a7a723058201540ed8f82b334522f0e3a11793ba18c1d184536d7b797b30adbba3ca9b7f52c0029 1000000 30 0

After triggering fibonacciNotify and event notify:

triggersmartcontract 417C5D1624B699C425355B99D1C8D188D367FA232D fibonacciNotify(uint256) 7 false 1000000 0000000000000000000000000000000000000000000000000000000000000000

Return Value:

    "block_number": 88,
    "block_timestamp": 1534767012000,
    "contract_address": "TMJnJcHfdP5rhmXVkwRYb1a9A6gS46PUm6",
    "event_name": "Notify",
    "result": [
    "transaction_id": "5c3747ffa94fc87a2188708a9e0758cbd01f000d3d01f6589651921930183f6a"

Return Format:

block_number: block height
block_timestamp: event time stamp
contract_address: contract address
event_name: event name
result: event parameter
transaction_id: transcation id

Blockchain Interaction

Use Tron-Web & Tron-Grid to interact with the Blockchain:

import TronWeb from 'TronWeb'

const HttpProvider = TronWeb.providers.HttpProvider; // Optional provider, can just use a url for the nodes instead

const fullNode = new HttpProvider(''); // Full node http endpoint
const solidityNode = new HttpProvider(''); // Solidity node http endpoint
const eventServer = ''; // Contract events http endpoint
const privateKey = 'da146374a75310b9666e834ee4a...c76217c5a495fff9f0d0';

const tronWeb = new TronWeb(
// The majority of the function calls are asynchronus, 
// meaning that they cannot return the result instantly.
// These methods therefore return a promise, which you can await.
const balance = await tronWeb.trx.getBalance(address);
console.log({ balance });

// You can also bind a `then` and `catch` method.
tronWeb.trx.getBalance(address).then(balance => {
console.log({ balance });
}).catch(err => console.error(err));

// If you'd like to use a similar API to Web3, provide a callback function.
tronWeb.trx.getBalance(address, (err, balance) => {
    return console.error(err);
    console.log({ balance });

Updated 2 years ago

Integrating Blockchain APIs

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.