Retrieve Transaction Data via RPC Methods (EVM)
Use eth_getTransactionReceipt for status and logs, eth_getTransactionByHash for basic details, and trace or debug methods for internal calls and reverts.
Ethereum and all EVM-compatible chains support various types of transactions, ranging from simple value transfers to complex smart contract interactions. Depending on the complexity of the transaction, you will need to choose the appropriate RPC method to analyze and debug it.
Transaction Types
- Simple ETH (or Native Token) Transfers
- Description: Transactions that send the chain's native token (e.g., ETH on Ethereum, BNB on Binance Smart Chain) from one address to another without interacting with smart contracts.
- Example: Sending 1 ETH from Address A to Address B.
- Smart Contract Interactions
- Description: Transactions that interact with smart contracts to execute functions, emit events, or perform token transfers.
- Example: Calling a
transferfunction on an ERC-20 token contract.
- Contract Deployments
- Description: Transactions that create a new smart contract on the blockchain.
- Example: Deploying an ERC-721 NFT contract.
- Failed Transactions
- Description: Transactions that fail due to insufficient gas, invalid input data, or contract-level reverts.
- Example: A transaction reverts due to a failed
requirecondition in a smart contract.
- Internal Transactions
- Description: Operations triggered within a transaction, such as contract-to-contract calls or value transfers initiated by a smart contract.
- Example: A swap operation in a decentralized exchange (DEX) contract.
Choosing the Right RPC Method
Here’s a table summarizing the best RPC methods to use based on your transaction type and the data you need:
| Feature | trace_transaction | eth_getTransactionReceipt | eth_getTransactionByHash | debug_traceTransaction |
|---|---|---|---|---|
| Internal Transactions | ✅ Detailed | ❌ Not included | ❌ Not included | ✅ Detailed |
| Gas Usage Details | ✅ Gas used per call | ✅ Total gas used for the transaction | ❌ Not included | ✅ Step-by-step gas usage |
| Event Logs | ❌ Not included | ✅ Final logs emitted | ❌ Not included | ✅ With callTracer and withLog: true |
| Failure Analysis | ✅ Shows which call reverted | ✅ Basic success/failure status | ❌ Not included | ✅ Opcode-level revert analysis |
| Contract Calls | ✅ Complete call stack of contract execution | ❌ Not included | ❌ Not included | ✅ Complete call stack and state changes |
| Revert Reason | ✅ Raw revert data in output | ❌ Status only (0x0 = failed) | ❌ Not available | ✅ Captures opcode-level revert reasons |
| Transaction Metadata | ✅ Block hash and number per trace | ✅ Includes block hash, number, etc. | ✅ Includes block hash, number, etc. | ❌ Not included |
| Execution Steps | ❌ Call-level only | ❌ Not included | ❌ Not included | ✅ Full trace of EVM execution |
| Use Case | Debugging and detailed transaction analysis | Verifying transaction outcome and logs | Checking raw transaction details | Advanced debugging of opcode execution |
NOTE
trace_*methods aren't available on every chain or node client. To check a chain, open its gateway's method list, for example Ethereum Mainnet /_methods.
Common Use Cases and Recommendations
1. Verifying a Transaction Outcome
- Scenario: Check if a transaction was successful and retrieve any emitted logs.
- Recommended Method:
eth_getTransactionReceipt - Example request (a token swap on Ethereum Mainnet):
curl --location 'https://ethereum-mainnet.gateway.tatum.io' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {YOUR_API_KEY}' \
--data '{
"jsonrpc":"2.0",
"method":"eth_getTransactionReceipt",
"params":["0xad72c4b37a731db12551b92a9c811638db4560b5664c15e79580e413622a1ab0"],
"id":1
}'In the response, status is 0x1 for a successful transaction and 0x0 for a failed one.
2. Retrieving Basic Transaction Details
- Scenario: Get details such as sender, receiver, gas, value, and input data.
- Recommended Method:
eth_getTransactionByHash - Example request:
curl --location 'https://ethereum-mainnet.gateway.tatum.io' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {YOUR_API_KEY}' \
--data '{
"jsonrpc":"2.0",
"method":"eth_getTransactionByHash",
"params":["0xad72c4b37a731db12551b92a9c811638db4560b5664c15e79580e413622a1ab0"],
"id":1
}'3. Debugging Failed Transactions
- Scenario: Analyze why a transaction failed or reverted.
- Recommended Methods:
trace_transaction,debug_traceTransaction - Example request (a reverted transaction on Ethereum Mainnet):
curl --location 'https://ethereum-mainnet.gateway.tatum.io' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {YOUR_API_KEY}' \
--data '{
"jsonrpc":"2.0",
"method":"trace_transaction",
"params":[
"0x05e5a1ba136bd6cf4aef8a39662d59af9e91d93b7f546343c0e89c9b065005c4"
],
"id":1
}'Each call that reverted has "error": "Reverted", and its result.output holds the raw revert data.
4. Analyzing Complex Smart Contract Interactions
- Scenario: Trace internal calls and value transfers within a transaction.
- Recommended Methods:
trace_transaction,debug_traceTransaction -
Example request (
debug_traceTransactionwith thecallTraceron the token swap):curl --location 'https://ethereum-mainnet.gateway.tatum.io' \ --header 'Content-Type: application/json' \ --header 'x-api-key: {YOUR_API_KEY}' \ --data '{ "jsonrpc":"2.0", "method":"debug_traceTransaction", "params":[ "0xad72c4b37a731db12551b92a9c811638db4560b5664c15e79580e413622a1ab0", {"tracer": "callTracer"} ], "id":1 }'
NOTEFind more about
debug_traceTransactionin Retrieve internal transactions from a transaction hash.
5. Extracting Logs from Transactions
- Scenario: Retrieve events emitted by a transaction for monitoring or debugging.
- Recommended Method:
eth_getTransactionReceipt -
Example request:
curl --location 'https://ethereum-mainnet.gateway.tatum.io' \ --header 'Content-Type: application/json' \ --header 'x-api-key: {YOUR_API_KEY}' \ --data '{ "jsonrpc":"2.0", "method":"eth_getTransactionReceipt", "params":["0xad72c4b37a731db12551b92a9c811638db4560b5664c15e79580e413622a1ab0"], "id":1 }'
Good to Know
DebugandTracemethods may require access to Archival Data- Some methods may be only available on Mainnet chains.
- The examples use Ethereum Mainnet. For another EVM chain, use its gateway URL from the list of supported blockchains.
- Find more about available authentication methods in Authentication.
Updated 1 day ago