TRON Developer Guide—TRX Functions

TRON DAO
4 min readJun 19, 2019

Get Current Block

tronWeb.trx.getCurrentBlock();

Returns the current block on the FullNode.

Get Block

tronWeb.trx.getBlock(12345);

Gets a block by height/ID. If none is provided, it returns the default block.

Get Block By Hash

tronWeb.trx.getBlockByHash("0000000000038809c59ee8409a3b6c051e369ef1096603c7ee723c16e2376c73");

Gets a block by block hash.

Get Block By Number

tronWeb.trx.getBlockByNumber(12345);

Gets a block by height or ID.

Get Block Transaction Account

tronWeb.trx.getBlockTransactionCount(12345);

Gets the count of transactions within a block.

Get Transaction From Block

tronWeb.trx.getTransactionFromBlock(12345);

Gets the array of transactions from a block, if there are any.

Get Transaction

tronWeb.trx.getTransaction("67af8c693f88146999ffa2748331aa0dae980a14bb553f4798ef37d7bed799ee");

Gets a transaction by transaction ID.

Get Transaction Info

tronWeb.trx.getTransactionInfo("0ab16c340e85d52c1179aceca5133e711a5850f4ea42d5bac2e8929a3330551d");

Gets the details for a transaction, including the fees and virtual machine events for a transaction.

Get Transactions to Address

tronWeb.trx.getTransactionsToAddress("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF", 30, 0);

Gets all the confirmed transactions sent to an address. This will not return any unconfirmed transactions.

Get Transactions from Address

tronWeb.trx.getTransactionsFromAddress("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF", 30, 0);

Gets the transactions sent from an address.

Get Transactions Related

tronWeb.trx.getTransactionsRelated("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF", "all", 30, 0);

Gets all transactions involving a specified address.

Get Account

tronWeb.trx.getAccount("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF");

Get account from address.

Get Balance

tronWeb.trx.getBalance("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF");

Get balance from address.

Get Bandwidth

tronWeb.trx.getBandwidth("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF");

Get bandwidth from address.

Get Tokens Issued By Address

tronWeb.trx.getTokensIssuedByAddress("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF");

Get tokens issued by address.

Get Token From ID

tronWeb.trx.getTokenFromID("WIN");

Get Token From ID

List Nodes

tronWeb.trx.listNodes();

List all nodes on the network.

Get Block Range

tronWeb.trx.getBlockRange(10,20);

Get block range.

List Super Representatives

tronWeb.trx.listSuperRepresentatives();

List all super representatives on the network.

Time Until Next Vote Cycle

tronWeb.trx.timeUntilNextVoteCycle();

Get time until next vote cycle.

Get Contract

tronWeb.trx.getContract("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF");

Returns the details of the contract at the specified address.

Sign

Important: Do not use this in any web / user-facing applications. This will expose the private key.

tronWeb.trx.sign(transaction = [...], "abc...gdfsgdf");

Signs a provided transaction object.

Send Raw Transaction

tronWeb.trx.sendRawTransaction(signedTransaction = [...]);

Broadcasts a signed raw transaction to the network.

Send Transaction

Important: Do not use this in any web / user-facing applications. This will expose the private key.

tronWeb.trx.sendTransaction("TXPHCzmAmjyERtWES6EXTYqUPfJfQSzp2m", 100, "abc...gdfsgdf");

Sends TRX from one address to another. Will create and broadcast the transaction if a private key is provided.

Send Token

Important: Do not use this in any web / user-facing applications. This will expose the private key.

tronWeb.trx.sendTransaction("TXPHCzmAmjyERtWES6EXTYqUPfJfQSzp2m", 100, "WIN", "abc...gdfsgdf");

Sends TRX from one address to another. Will create and broadcast the transaction if a private key is provided.

Get Account Resources

tronWeb.trx.getAccountResources("TXPHCzmAmjyERtWES6EXTYqUPfJfQSzp2m");

Get resources from account.

--

--