Docs

eth_getTransactionReceipt - Get Receipt

Retrieve the receipt of a transaction including status, gas used, and logs on Neuroweb Mainnet. Essential for confirming transaction execution.

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

Common Use Cases

1. Smart Contract Event Monitoring

JavaScript
// 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

JavaScript
// 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

JavaScript
// 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()
    }
  };
}