TRON — Methods (2/3)
API reference for TRON. All methods ->
eth_getBlockByNumber
Returns information for the block specified by block number.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):-
<string>(quantity|tag): either the hex value of a block number or one of the following block tags:earliest: the lowest numbered block available on the client.latest: the most recent block in the canonical chain observed by the client; this block can be re-orged out of the canonical chain even under healthy/normal conditions.
-
<boolean>: iftrueit returns the full transaction objects, iffalse— only the hashes of the transactions.
-
Returns
<object>: a block object, or null when no block was found:number(string; quantity): the block number; null when it's a pending block.hash(string; data, 32 bytes): the hash of the block; null when it's a pending block.parentHash(string; data, 32 bytes): the hash of the parent block.nonce(string; data, 8 bytes): the hash of the generated proof-of-work; null when it's a pending block.sha3Uncles(string; data, 32 bytes): SHA3 of the uncles data in the block.logsBloom(string; data, 256 bytes): the bloom filter for the logs of the block. null when its pending block.transactionsRoot(string; data, 32 bytes): the root of the transaction trie of the block.stateRoot(string; data, 32 bytes): the root of the final state trie of the block.receiptsRoot(string; data, 32 bytes): the root of the receipts trie of the block.miner(string; data, 20 bytes): the address of the beneficiary to whom the mining rewards were given.difficulty(string; quantity): the difficulty for this block.totalDifficulty(string; quantity): the total difficulty of the chain until this block.extraData(string; data): the extra data field of this block.size(string; quantity): the size of this block in bytes.gasLimit(string; quantity): the maximum gas allowed in this block.gasUsed(string; quantity): the total used gas by all transactions in this block.timestamp(string; quantity): the unix timestamp for when the block was collated.transactions(array of strings): an array of transaction objects, or 32 bytes transaction hashes depending on the last given parameter.uncles(array of strings): an array of uncle hashes.
Request example
curl -X POST https://rpc.ankr.com/tron_jsonrpc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": ["0x1b4", false],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"baseFeePerGas": "0x0",
"difficulty": "0x0",
"extraData": "0x",
"gasLimit": "0x0",
"gasUsed": "0x0",
"hash": "0x00000000000001b471ba79b1cf4cfe70ff48558f7a2218f52541d54f3403d091",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"miner": "0x5095d4f4d26ebc672ca12fc0e3a48d6ce3b169d2",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"number": "0x1b4",
"parentHash": "0x00000000000001b36c300ca00603e1f4145045fc9667d4b5e1c8e89d91d6446c",
"receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"sha3Uncles": "0x0000000000000000000000000000000000000000000000000000000000000000",
"size": "0xad",
"stateRoot": "0x",
"timestamp": "0x5b304fee",
"totalDifficulty": "0x0",
"transactions": [],
"transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"uncles": []
}
}
eth_getTransactionByHash
Returns information on a transaction specified by transaction hash.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<string>(data, 32 bytes): a transaction hash.
Returns
blockHash(string; data, 32 bytes): a hash of the block containing the transaction; null when it's pending.blockNumber(string; quantity): a number of the block containing the transaction; null when it's pending.from(string; data, 20 bytes): an address of the sender.gas(string; quantity): the gas provided by the sender.gasPrice(string; quantity): the gas price provided by the sender in wei.hash(string; data, 32 bytes): the hash of the transaction.input(string; data): the data send along with the transaction.nonce(string; quantity): the number of transactions made by the sender prior to this one.to(string: data, 20 bytes): an address of the receiver: null when it's a contract creation transaction.transactionIndex(string; quantity): the transaction index position in the block; null when it's pending.value(string; quantity): the value transferred in wei.v(string; quantity): ECDSA recovery ID.r(string; quantity): ECDSA signature r.s(string; quantity): ECDSA signature s.
Request example
curl -X POST https://rpc.ankr.com/tron_jsonrpc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByHash",
"params": ["5f72a4ff71f906fb53958a68e8a56613ff56752649ca9ed0fa879890f5f06098"],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"blockHash": "0x0000000002fb6540b72dbe6efa2568db23bdc1155c30253ecbeb180b344c7366",
"blockNumber": "0x2fb6540",
"from": "0x7507386fe92eed44c61281ac9513c9c64f8e65d2",
"gas": "0x0",
"gasPrice": "0x1a4",
"hash": "0x5f72a4ff71f906fb53958a68e8a56613ff56752649ca9ed0fa879890f5f06098",
"input": "0x",
"nonce": "0x0000000000000000",
"r": "0x352d87789df75779efd5abbd5dc2b36fdadd64c5b98848107d98a7d46c2cbffe",
"s": "0x17d117d81dd5a7336ebd3fe5453fce71fa35a1f50b633eaf032ae8bb5d9d9662",
"to": "0x08b0a04bdfbb7ee6258b19a4d8a57bd41a88f9f1",
"transactionIndex": "0x6c",
"type": "0x0",
"v": "0x1b",
"value": "0x1"
}
}
eth_getTransactionByBlockHashAndIndex
Returns information on a transaction specified by block hash and transaction index position.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<string>(data, 32 bytes): a block hash.<string>(quantity): a transaction index position.
Returns
blockHash(string; data, 32 bytes): a hash of the block containing the transaction; null when it's pending.blockNumber(string; quantity): a number of the block containing the transaction; null when it's pending.from(string; data, 20 bytes): an address of the sender.gas(string; quantity): the gas provided by the sender.gasPrice(string; quantity): the gas price provided by the sender in wei.hash(string; data, 32 bytes): the hash of the transaction.input(string; data): the data send along with the transaction.nonce(string; quantity): the number of transactions made by the sender prior to this one.to(string: data, 20 bytes): an address of the receiver: null when it's a contract creation transaction.transactionIndex(string; quantity): the transaction index position in the block; null when it's pending.value(string; quantity): the value transferred in wei.v(string; quantity): ECDSA recovery ID.r(string; quantity): ECDSA signature r.s(string; quantity): ECDSA signature s.
Request example
curl -X POST https://rpc.ankr.com/tron_jsonrpc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByBlockHashAndIndex",
"params": ["00000000020ef11c87517739090601aa0a7be1de6faebf35ddb14e7ab7d1cc5b", "0x0"],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"blockHash": "0x00000000020ef11c87517739090601aa0a7be1de6faebf35ddb14e7ab7d1cc5b",
"blockNumber": "0x20ef11c",
"from": "0xb4f1b6e3a1461266b01c2c4ff9237191d5c3d5ce",
"gas": "0x0",
"gasPrice": "0x8c",
"hash": "0x8dd26d1772231569f022adb42f7d7161dee88b97b4b35eeef6ce73fcd6613bc2",
"input": "0x",
"nonce": "0x0000000000000000",
"r": "0x6212a53b962345fb8ab02215879a2de05f32e822c54e257498f0b70d33825cc5",
"s": "0x6e04221f5311cf2b70d3aacfc444e43a5cf14d0bf31d9227218efaabd9b5a812",
"to": "0x047d4a0a1b7a9d495d6503536e2a49bb5cc72cfe",
"transactionIndex": "0x0",
"type": "0x0",
"v": "0x1b",
"value": "0x203226"
}
}
eth_getTransactionByBlockNumberAndIndex
Returns information on a transaction by block number and transaction index position.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<string>(quantity|tag): either the hex value of a block number or one of the following block tags:earliest: the lowest numbered block available on the client.latest: the most recent block in the canonical chain observed by the client; this block can be re-orged out of the canonical chain even under healthy/normal conditions.
<string>(quantity): the transaction index position.
Returns
blockHash(string; data, 32 bytes): a hash of the block containing the transaction; null when it's pending.blockNumber(string; quantity): a number of the block containing the transaction; null when it's pending.from(string; data, 20 bytes): an address of the sender.gas(string; quantity): the gas provided by the sender.gasPrice(string; quantity): the gas price provided by the sender in wei.hash(string; data, 32 bytes): the hash of the transaction.input(string; data): the data send along with the transaction.nonce(string; quantity): the number of transactions made by the sender prior to this one.to(string: data, 20 bytes): an address of the receiver: null when it's a contract creation transaction.transactionIndex(string; quantity): the transaction index position in the block; null when it's pending.value(string; quantity): the value transferred in wei.v(string; quantity): ECDSA recovery ID.r(string; quantity): ECDSA signature r.s(string; quantity): ECDSA signature s.
Request example
curl -X POST https://rpc.ankr.com/tron_jsonrpc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByBlockNumberAndIndex",
"params": ["0x2FB6562", "0x0"],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"blockHash": "0x0000000002fb6562c886d5f844a697b99c73e25b79cb8d3de8771cca9c3700d4",
"blockNumber": "0x2fb6562",
"from": "0x9d959e29ca58da6583b460e54d329e3975ddc3b4",
"gas": "0xacc4",
"gasPrice": "0x1a4",
"hash": "0x50f952272174ec81359e91a229b171e881e3a7db44400b53f81ccecf038b2564",
"input": "0x23b872dd0000000000000000000000417db40dca0d40898c18ab574303c5ff139176b11d0000000000000000000000419339b7a574abc3f201ab56dd66b72964402080fe0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"r": "0x513d8b9990aa2f18cb744d2a1056b75be4fa16bd48108e2010ae904fcffa45d7",
"s": "0xa622e4e997445f1cff980be4d205c44d2fd1781ab5e863453f8e8fc57d97ec77",
"to": "0xa614f803b6fd780986a42c78ec9c7f77e6ded13c",
"transactionIndex": "0x0",
"type": "0x0",
"v": "0x1b",
"value": "0x0"
}
}
eth_getTransactionReceipt
Returns the receipt of a transaction by transaction hash.
The receipt is not available for pending transactions.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<string>(data, 32 bytes): a hash of the transaction.
Returns
-
object: a transaction receipt object, or null when no receipt was found:-
transactionHash(string; data, 32 bytes): a hash of the transaction. -
transactionIndex(string; quantity): the transactions index position in the block. -
blockHash(string; data, 32 bytes): a hash of the block containing the transaction. -
blockNumber(string; quantity): a number of the block containing the transaction. -
from(string; data, 20 bytes): an address of the sender. -
to(string; data, 20 bytes): an address of the receiver; null when it's a contract creation transaction. -
cumulativeGasUsed(string; quantity): the total amount of gas used when this transaction was executed in the block. -
effectiveGasPrice(string; quantity): the sum of the base fee and tip paid per unit of gas. -
gasUsed(string; quantity): the amount of gas used by this specific transaction alone. -
contractAddress(string; data, 20 bytes): the contract address created, if the transaction was a contract creation, otherwise null. -
logs(array): an array of log objects, which this transaction generated. -
logsBloom(string; data, 256 bytes): a bloom filter for light clients to quickly retrieve related logs. -
type(string; data): the transaction type,0x00for legacy transactions,0x01for access list types,0x02for dynamic fees. It also returns either of the following:root(string; data, 32 bytes): a post-transaction stateroot (pre Byzantium).status(string; quantity): either 1 (success) or 0 (failure).
-
Request example
curl -X POST https://rpc.ankr.com/tron_jsonrpc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionReceipt",
"params": ["c9af231ad59bcd7e8dcf827afd45020a02112704dce74ec5f72cb090aa07eef0"],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"blockHash": "0x00000000020ef11c87517739090601aa0a7be1de6faebf35ddb14e7ab7d1cc5b",
"blockNumber": "0x20ef11c",
"contractAddress": null,
"cumulativeGasUsed": "0x646e2",
"effectiveGasPrice": "0x8c",
"from": "0x6eced5214d62c3bc9eaa742e2f86d5c516785e14",
"gasUsed": "0x0",
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": "0x1",
"to": "0x0697250b9d73b460a9d2bbfd8c4cacebb05dd1f1",
"transactionHash": "0xc9af231ad59bcd7e8dcf827afd45020a02112704dce74ec5f72cb090aa07eef0",
"transactionIndex": "0x6",
"type": "0x0"
}
}
eth_getUncleByBlockHashAndIndex
Returns information about an uncle of a block by hash and uncle index position.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<string>(data, 32 bytes): the hash of a block.<string>(quantity): the uncle's index position.
Returns
<object>: a block object, or null when no block was found:number(string; quantity): the block number; null when it's a pending block.hash(string; data, 32 bytes): the hash of the block; null when it's a pending block.parentHash(string; data, 32 bytes): the hash of the parent block.nonce(string; data, 8 bytes): the hash of the generated proof-of-work; null when it's a pending block.sha3Uncles(string; data, 32 bytes): SHA3 of the uncles data in the block.logsBloom(string; data, 256 bytes): the bloom filter for the logs of the block. null when its pending block.transactionsRoot(string; data, 32 bytes): the root of the transaction trie of the block.stateRoot(string; data, 32 bytes): the root of the final state trie of the block.receiptsRoot(string; data, 32 bytes): the root of the receipts trie of the block.miner(string; data, 20 bytes): the address of the beneficiary to whom the mining rewards were given.difficulty(string; quantity): the difficulty for this block.totalDifficulty(string; quantity): the total difficulty of the chain until this block.extraData(string; data): the extra data field of this block.size(string; quantity): the size of this block in bytes.gasLimit(string; quantity): the maximum gas allowed in this block.gasUsed(string; quantity): the total used gas by all transactions in this block.timestamp(string; quantity): the unix timestamp for when the block was collated.transactions(array of strings): an array of transaction objects, or 32 bytes transaction hashes depending on the last given parameter.uncles(array of strings): an array of uncle hashes.
Request example
curl -X POST https://rpc.ankr.com/tron_jsonrpc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getUncleByBlockHashAndIndex",
"params": ["0000000002fb6562c886d5f844a697b99c73e25b79cb8d3de8771cca9c3700d4", "0x0"],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"difficulty": "0x4ea3f27bc",
"extraData": "0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32",
"gasLimit": "0x1388",
"gasUsed": "0x0",
"hash": "0xdc0818cf78f21a8e70579cb46a43643f78291264dda342ae31049421c82d21ae",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"miner": "0xbb7b8287f3f0a933474a79eae42cbca977791171",
"mixHash": "0x4fffe9ae21f1c9e15207b1f472d5bbdd68c9595d461666602f2be20daf5e7843",
"nonce": "0x689056015818adbe",
"number": "0x1b4",
"parentHash": "0xe99e022112df268087ea7eafaf4790497fd21dbeeb6bd7a1721df161a6657a54",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"size": "0x220",
"stateRoot": "0xddc8b0234c2e0cad087c8b389aa7ef01f7d79b2570bccb77ce48648aa61c904d",
"timestamp": "0x55ba467c",
"totalDifficulty": "0x78ed983323d",
"transactions": [],
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncles": []
}
}