Find Transaction Data via RPC Methods (EVM)

This article explains common transaction types, their characteristics, and which RPC methods are best suited for extracting relevant data.

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

  1. 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.
  2. Smart Contract Interactions
    • Description: Transactions that interact with smart contracts to execute functions, emit events, or perform token transfers.
    • Example: Calling a transfer function on an ERC-20 token contract.
  3. Contract Deployments
    • Description: Transactions that create a new smart contract on the blockchain.
    • Example: Deploying an ERC-721 NFT contract.
  4. 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 require condition in a smart contract.
  5. 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:

Featuretrace_transactioneth_getTransactionReceipteth_getTransactionByHashdebug_traceTransaction
Internal Transactions✅ Detailed❌ Not included❌ Not included✅ Detailed
Gas Usage Details✅ Step-by-step gas consumption✅ Total gas used for the transaction❌ Not included✅ Step-by-step gas usage
Event Logs✅ Intermediate logs (if needed)✅ Final logs emitted❌ Not included❌ Not included
Failure Analysis✅ Shows revert reasons and opcode causing it✅ 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✅ Captures detailed revert reasons✅ Returns high-level revert reason❌ Not available✅ Captures opcode-level revert reasons
Transaction Metadata❌ Not included✅ Includes block hash, number, etc.✅ Includes block hash, number, etc.❌ Not included
Execution Steps✅ Full trace of EVM execution❌ Not included❌ Not included✅ Full trace of EVM execution
Use CaseDebugging and detailed transaction analysisVerifying transaction outcome and logsChecking raw transaction detailsAdvanced debugging of opcode execution

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:
curl --location 'https://ethereum-classic-mainnet.gateway.tatum.io' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {YOUR_API_KEY}' \
--data '{
    "jsonrpc":"2.0",
    "method":"eth_getTransactionReceipt",
    "params":["0x1393410752022c9e61de2914166c7ad1e00d997bf4617da5b3da1855175aa28a"],
    "id":1
}'

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-classic-mainnet.gateway.tatum.io' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {YOUR_API_KEY}' \
--data '{
    "jsonrpc":"2.0",
    "method":"eth_getTransactionByHash",
    "params":["0x1393410752022c9e61de2914166c7ad1e00d997bf4617da5b3da1855175aa28a"],
    "id":1
}'

3. Debugging Failed Transactions

  • Scenario: Analyze why a transaction failed or reverted.
  • Recommended Methods: trace_transaction, debug_traceTransaction
  • Example request:
curl --location 'https://ethereum-classic-mainnet.gateway.tatum.io' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {YOUR_API_KEY}' \
--data '{
	"jsonrpc":"2.0",
	"method":"trace_transaction",
	"params":[
		"0x1393410752022c9e61de2914166c7ad1e00d997bf4617da5b3da1855175aa28a"
	],
	"id":1
}'

4. Analyzing Complex Smart Contract Interactions

  • Scenario: Trace internal calls and value transfers within a transaction.
  • Recommended Methods: trace_transaction, debug_traceTransaction
  • Example request:
    curl --location 'https://ethereum-classic-mainnet.gateway.tatum.io' \
    --header 'Content-Type: application/json' \
    --header 'x-api-key: {YOUR_API_KEY}' \
    --data '{
    	"jsonrpc":"2.0",
    	"method":"trace_transaction",
    	"params":[
    		"0x1393410752022c9e61de2914166c7ad1e00d997bf4617da5b3da1855175aa28a"
    	],
    	"id":1
    }'
    

📘

NOTE

Find more about debug_traceTransaction HERE .

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-classic-mainnet.gateway.tatum.io' \
    --header 'Content-Type: application/json' \
    --header 'x-api-key: {YOUR_API_KEY}' \
    --data '{
        "jsonrpc":"2.0",
        "method":"eth_getTransactionReceipt",
        "params":["0x1393410752022c9e61de2914166c7ad1e00d997bf4617da5b3da1855175aa28a"],
        "id":1
    }'
    

Good to Know

  • Debug and Trace methods may require access to Archival Data
  • Some methods may be only available on Mainnet chains.
  • Find the list of supported blockchains HERE.
  • Find more about available authentication methods HERE.