TRX Functions

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.

ValueDescription
blockID or height for the block.

Get Block By Hash

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

Gets a block by block hash.

ValueDescription
block HashHash of block.

Get Block By Number

tronWeb.trx.getBlockByNumber(12345);

Gets a block by height or ID.

ValueDescription
blockID or height for the block.

Get Block Transaction Account

tronWeb.trx.getBlockTransactionCount(12345);

Gets the count of transactions within a block.

ValueDescription
blockID or height for the block.

Get Transaction From Block

tronWeb.trx.getTransactionFromBlock(12345);

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

ValueDescription
blockID or height for the block.

Get Transaction

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

Gets a transaction by transaction ID.

ValueDescription
transaction hashHash of the transaction.

Get Transaction Info

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

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

ValueDescription
transaction hashHash of 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.

ValueDescription
addressAddress to query.
limitLimit amount of returned tx.
offsetOffset to return from.

Get Transactions from Address

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

Gets the transactions sent from an address.

ValueDescription
addressAddress to query.
limitLimit the number of returned tx.
offsetOffset to return from.

Get Transactions Related

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

Gets all transactions involving a specified address.

ValueDescription
addressAddress to query from.
directionThe specified direction of transactions.
limitLimit the number of returned tx.
offsetOffset to start from.

Get Account

tronWeb.trx.getAccount("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF");

Get account from address.

ValueDescription
AddressAddress of account.

Get Balance

tronWeb.trx.getBalance("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF");

Get balance from address.

ValueDescription
AddressAddress of account.

Get Bandwidth

tronWeb.trx.getBandwidth("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF");

Get bandwidth from address.

ValueDescription
AddressAddress of account.

Get Tokens Issued By Address

tronWeb.trx.getTokensIssuedByAddress("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF");

Get tokens issued by address.

ValueDescription
AddressAddress of account.

Get Token From ID

tronWeb.trx.getTokenFromID("WIN");

Get Token From ID

ValueDescription
Token IDID of token.

List Nodes

tronWeb.trx.listNodes();

List all nodes on the network.

Get Block Range

tronWeb.trx.getBlockRange(10,20);

Get block range.

ValueDescription
Minimum BlockMinimum block height or ID in the 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.

ValueDescription
Contract AddressAddress of contract.

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.

AddressTo account.
AmountAmount you want to send.
Private KeyPrivate key of account to sign transaction.

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.

ValueDescription
AddressTo account.
AmountAmount you want to send.
TokenID of token.
Private KeyPrivate key of account to sign transaction.

Get Account Resources

tronWeb.trx.getAccountResources("TXPHCzmAmjyERtWES6EXTYqUPfJfQSzp2m");

Get resources from account.

ValueDescription
AddressAddress of account.

What’s Next