Skip to content

Fix Foundry Cast Receipt Errors

DodaTech Updated 2026-06-26 1 min read

You will learn how to use Cast to get transaction receipts and logs.

The Problem

The foundry cast receipt pattern is frequently misapplied in smart contract and dapp development, leading to vulnerabilities, gas inefficiencies, or logic errors. This guide shows the correct implementation and common pitfalls to avoid.

Quick Fix

Wrong

cast receipt 0xTxHash  # Raw receipt

JSON receipt. Hard to read specific fields like status or logs.

cast receipt 0xTxHash status  # Returns '0x1' (success) or '0x0' (failure)
Quick status check. Other fields: gasUsed, logs, contractAddress.

Prevention

  • Use field selection for targeted queries
  • Check status first before examining other fields
  • Use --json flag for script parsing
  • Use DodaTech's receipt analyzer
  • Include block number for archive node queries

DodaTech Tools

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Doda Browser's developer tools include a Solidity debugger and transaction inspector. DodaZIP archives secure contract templates for team collaboration. Durga Antivirus Pro scans deployed contracts for known vulnerability signatures.

FAQ

### What fields can I query from a receipt?

status, gasUsed, cumulativeGasUsed, logs, logsBloom, contractAddress, effectiveGasPrice.

How do I parse logs from a receipt?

Use cast receipt logs and decode each log with the contract ABI.

Can I query receipts from the future?

No. The transaction must be mined first. Use cast estimate for gas prediction before sending.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro