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.
Value | Description |
---|---|
block | ID or height for the block. |
Get Block By Hash
tronWeb.trx.getBlockByHash("0000000000038809c59ee8409a3b6c051e369ef1096603c7ee723c16e2376c73");
Gets a block by block hash.
Value | Description |
---|---|
block Hash | Hash of block. |
Get Block By Number
tronWeb.trx.getBlockByNumber(12345);
Gets a block by height or ID.
Value | Description |
---|---|
block | ID or height for the block. |
Get Block Transaction count
tronWeb.trx.getBlockTransactionCount(12345);
Gets the count of transactions within a block.
Value | Description |
---|---|
block | ID 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.
Value | Description |
---|---|
block | ID or height for the block. |
Get Transaction
tronWeb.trx.getTransaction("67af8c693f88146999ffa2748331aa0dae980a14bb553f4798ef37d7bed799ee");
Gets a transaction by transaction ID.
Value | Description |
---|---|
transaction hash | Hash 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.
Value | Description |
---|---|
transaction hash | Hash 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.
Value | Description |
---|---|
address | Address to query. |
limit | Limit amount of returned tx. |
offset | Offset to return from. |
Get Transactions from Address
tronWeb.trx.getTransactionsFromAddress("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF", 30, 0);
Gets the transactions sent from an address.
Value | Description |
---|---|
address | Address to query. |
limit | Limit the number of returned tx. |
offset | Offset to return from. |
Get Transactions Related
tronWeb.trx.getTransactionsRelated("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF", "all", 30, 0);
Gets all transactions involving a specified address.
Value | Description |
---|---|
address | Address to query from. |
direction | The specified direction of transactions. |
limit | Limit the number of returned tx. |
offset | Offset to start from. |
Get Account
tronWeb.trx.getAccount("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF");
Get account from address.
Value | Description |
---|---|
Address | Address of account. |
Get Balance
tronWeb.trx.getBalance("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF");
Get balance from address.
Value | Description |
---|---|
Address | Address of account. |
Get Bandwidth
tronWeb.trx.getBandwidth("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF");
Get bandwidth from address.
Value | Description |
---|---|
Address | Address of account. |
Get Tokens Issued By Address
tronWeb.trx.getTokensIssuedByAddress("TNDFkUNA2TukukC1Moeqj61pAS53NFchGF");
Get tokens issued by address.
Value | Description |
---|---|
Address | Address of account. |
Get Token From ID
tronWeb.trx.getTokenFromID("WIN");
Get Token From ID
Value | Description |
---|---|
Token ID | ID of token. |
List Nodes
tronWeb.trx.listNodes();
List all nodes on the network.
Get Block Range
tronWeb.trx.getBlockRange(10,20);
Get block range.
Value | Description |
---|---|
Minimum Block | Minimum 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.
Value | Description |
---|---|
Contract Address | Address 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.
Address | To account. |
Amount | Amount you want to send. |
Private Key | Private 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.
Value | Description |
---|---|
Address | To account. |
Amount | Amount you want to send. |
Token | ID of token. |
Private Key | Private key of account to sign transaction. |
Get Account Resources
tronWeb.trx.getAccountResources("TXPHCzmAmjyERtWES6EXTYqUPfJfQSzp2m");
Get resources from account.
Value | Description |
---|---|
Address | Address of account. |
Updated about 4 years ago