⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

eth_getTransactionReceipt

Returns the receipt of a transaction by transaction hash. Provides execution status, gas consumption, and emitted logs.

When to Use This Method

eth_getTransactionReceipt is essential for:

  • Transaction Confirmation - Verify successful execution
  • Event Monitoring - Access emitted logs and events
  • Gas Analysis - Track actual gas consumption
  • Contract Deployment - Get deployed contract addresses

Parameters

  1. Transaction Hash - DATA, 32 Bytes
    • Hash of the executed transaction
    • Format: 0x followed by 64 hexadecimal characters
{
"jsonrpc": "2.0",
"method": "eth_getTransactionReceipt",
"params": [
"${S.txHash}"
],
"id": 1
}

Returns

Object - Receipt object, or null when no receipt was found:

  • transactionHash - Hash of the transaction
  • transactionIndex - Position in the block
  • blockHash - Hash of the block
  • blockNumber - Block number
  • from - Sender address
  • to - Receiver address (null for contract creation)
  • cumulativeGasUsed - Total gas used in block up to this transaction
  • gasUsed - Gas used by this specific transaction
  • effectiveGasPrice - Actual gas price paid
  • contractAddress - Created contract address (if contract creation)
  • logs - Array of log objects from events
  • logsBloom - Bloom filter for logs
  • status - 0x1 (success) or 0x0 (failure)
  • type - Transaction type
  • l1Fee - L1 data posting fee (Ethereum specific)
  • l1GasPrice - L1 gas price used (Ethereum specific)
  • l1GasUsed - L1 gas consumed (Ethereum specific)

Implementation Examples

curl -X POST https://api-ethereum-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionReceipt",
"params": [
"undefined"
],
"id": 1
}'

Common Use Cases

1. Smart Contract Event Monitoring

// Monitor DeFi protocol events
async function monitorDeFiEvents(txHash) {
const DEFI_ABI = [
"event Deposit(address indexed user, uint256 amount, uint256 shares)",
"event Withdraw(address indexed user, uint256 amount, uint256 shares)",
"event Swap(address indexed user, address tokenIn, address tokenOut, uint256 amountIn, uint256 amountOut)"
];

const processor = new ReceiptProcessor(provider);
const events = await processor.parseEvents(txHash, DEFI_ABI);

for (const event of events) {
switch(event.name) {
case 'Deposit':
console.log(`User ${event.args.user} deposited ${event.args.amount}`);
break;
case 'Withdraw':
console.log(`User ${event.args.user} withdrew ${event.args.amount}`);
break;
case 'Swap':
console.log(`Swap: ${event.args.amountIn} ${event.args.tokenIn} -> ${event.args.amountOut} ${event.args.tokenOut}`);
break;
}
}

return events;
}

2. Failed Transaction Debugging

// Debug failed transactions
async function debugFailedTransaction(txHash) {
const receipt = await provider.getTransactionReceipt(txHash);

if (!receipt) {
return { error: 'Receipt not found' };
}

if (receipt.status === 1) {
return { status: 'success' };
}

// Get transaction details for more context
const tx = await provider.getTransaction(txHash);

// Try to decode revert reason
try {
const result = await provider.call({
to: tx.to,
from: tx.from,
data: tx.data,
value: tx.value,
gasLimit: tx.gasLimit
}, tx.blockNumber - 1);
} catch (error) {
return {
status: 'failed',
gasUsed: receipt.gasUsed.toString(),
gasLimit: tx.gasLimit.toString(),
revertReason: error.reason || error.message,
block: receipt.blockNumber
};
}
}

3. Multi-Transaction Batch Analysis

// Analyze batch of transactions
async function analyzeBatch(txHashes) {
const processor = new ReceiptProcessor(provider);
const results = [];

for (const hash of txHashes) {
const receipt = await processor.getReceipt(hash);
const cost = await processor.calculateTotalCost(hash);

results.push({
hash: hash,
status: receipt?.status,
gasUsed: receipt?.gasUsed,
totalCost: cost?.totalCost,
l1Cost: cost?.l1Cost,
blockNumber: receipt?.blockNumber
});
}

// Calculate statistics
const successful = results.filter(r => r.status === 'success').length;
const totalGas = results.reduce((sum, r) => sum + BigInt(r.gasUsed || 0), 0n);

return {
transactions: results,
statistics: {
total: txHashes.length,
successful: successful,
failed: txHashes.length - successful,
totalGasUsed: totalGas.toString()
}
};
}

Error Handling

Error ScenarioDescriptionSolution
null receiptTransaction not mined yetWait and retry
Status 0x0Transaction failedCheck revert reason
Missing L1 fee dataOld transaction formatHandle gracefully
async function robustGetReceipt(txHash, maxRetries = 10) {
for (let i = 0; i < maxRetries; i++) {
try {
const receipt = await provider.getTransactionReceipt(txHash);

if (receipt) {
// Ensure all fields are present
return {
...receipt,
l1Fee: receipt.l1Fee || 0n,
l1GasPrice: receipt.l1GasPrice || 0n,
l1GasUsed: receipt.l1GasUsed || 0n,
effectiveGasPrice: receipt.effectiveGasPrice || receipt.gasPrice
};
}

// Exponential backoff
await new Promise(resolve =>
setTimeout(resolve, Math.min(1000 * Math.pow(2, i), 30000))
);
} catch (error) {
if (i === maxRetries - 1) throw error;
}
}

return null;
}

Need help? Contact our support team or check the Ethereum documentation.