Transaction Receipt
Retrieves the execution receipt for a confirmed blockchain transaction, including status, gas used, and emitted events.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Client ID - The client ID from the Create Client node.
- Hash - The transaction hash to query (must start with "0x").
Output
- Receipt - An object containing the transaction execution results, including status, gas used, logs, and contract address (if applicable).
How It Works
The Transaction Receipt node retrieves the execution result of a transaction. When executed, the node:
- Validates the Client ID and transaction hash
- Connects to the blockchain using an Ethereum client
- Queries for the transaction receipt
- Returns the complete receipt object with all execution details
Requirements
- A valid Client ID from the Create Client node
- A transaction hash for a confirmed transaction
- The transaction must be mined and included in a block
Error Handling
The node will return errors for:
- Empty or invalid Client ID
- Client connection failure
- Invalid hash format (must start with "0x")
- Transaction not found or not yet confirmed
- Network connection issues
Receipt Object Structure
{
"transactionHash": "0x...", // Transaction hash
"transactionIndex": 45, // Position in block
"blockHash": "0x...", // Block hash
"blockNumber": 15000000, // Block number
"from": "0x...", // Sender address
"to": "0x...", // Recipient address (null for contract deployment)
"cumulativeGasUsed": 1234567, // Total gas used in block up to this tx
"gasUsed": 65000, // Gas consumed by this transaction
"contractAddress": "0x..." | null, // New contract address (if deployment)
"logs": [...], // Array of log entries (events)
"logsBloom": "0x...", // Bloom filter for logs
"status": 1, // 1 = success, 0 = failure
"effectiveGasPrice": "50000000000" // Actual gas price paid
}
Transaction Status
Status Field:
1- Transaction succeeded0- Transaction failed/reverted
Always check status before processing results!
Usage Notes
- Only works for confirmed transactions (already mined)
- Returns error if transaction is still pending
- Use in a retry loop if checking recent transactions
- The status field is critical for determining success
- Logs contain emitted events from smart contracts
- Gas used is the actual amount, often less than the limit
- Contract deployments have contractAddress populated
Example
Checking transaction success:
Inputs:
- Client ID:
7e8f9a0b-1c2d-3e4f-5a6b-7c8d9e0f1a2b - Hash:
0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
Output:
{
"transactionHash": "0x1234...",
"blockNumber": 15123456,
"from": "0x742d35...",
"to": "0xA0b869...",
"gasUsed": 52341,
"status": 1,
"logs": [
{
"address": "0xA0b869...",
"topics": ["0xddf252ad..."],
"data": "0x..."
}
]
}
Failed transaction:
{
"transactionHash": "0xabcd...",
"blockNumber": 15123457,
"gasUsed": 65000, // Used all gas
"status": 0, // Failed!
"logs": [] // No events emitted
}
Common Use Cases
Confirmation Checking: Verify a transaction executed successfully.
Gas Cost Calculation: Determine actual gas consumed for cost analysis.
Event Processing: Extract and process events emitted by contracts.
Deployment Verification: Get the address of newly deployed contracts.
Transaction Finality: Confirm transactions have been permanently recorded.
Error Handling: Detect failed transactions and handle appropriately.
Extracting Key Information
Check if successful:
if (receipt.status === 1) {
// Success - proceed with next steps
} else {
// Failed - handle error, possibly retry
}
Get actual gas cost:
actualCost = receipt.gasUsed * receipt.effectiveGasPrice
// Convert to ETH for display
costInETH = actualCost / 10^18
Get deployed contract address:
if (receipt.contractAddress !== null) {
newContractAddress = receipt.contractAddress
}
Count events emitted:
eventCount = receipt.logs.length
Retry Pattern for Recent Transactions
maxRetries = 10
retryDelay = 3000 // 3 seconds
for (let i = 0; i < maxRetries; i++) {
try {
receipt = getTransactionReceipt(hash)
// Got receipt, check status
if (receipt.status === 1) {
// Success!
break
} else {
// Failed transaction
handleFailure()
break
}
} catch (error) {
if (i === maxRetries - 1) {
// Timeout - transaction not confirmed
handleTimeout()
} else {
// Wait and retry
wait(retryDelay)
}
}
}
Understanding Logs/Events
Structure of a log entry:
{
"address": "0x...", // Contract that emitted the event
"topics": [ // Indexed event parameters
"0x...", // Event signature hash
"0x..." // Indexed parameter values
],
"data": "0x...", // Non-indexed parameters
"blockNumber": 15000000,
"transactionHash": "0x...",
"transactionIndex": 45,
"blockHash": "0x...",
"logIndex": 67,
"removed": false
}
Decoding events: Use the Decode node with the contract ABI to parse log data.
Gas Analysis
Gas efficiency:
gasUsed = receipt.gasUsed
gasLimit = originalTransaction.gas
efficiency = (gasUsed / gasLimit) * 100
if (efficiency < 50) {
// Very inefficient, could lower gas limit
}
Refund calculation:
gasLimit = 100000
gasUsed = 65000
gasSaved = gasLimit - gasUsed // 35000
// Note: You only pay for gasUsed
Integration Example
Complete transaction flow with confirmation:
- Send Transaction - Execute transaction
- Store Hash - Save transaction hash
- Wait - Delay 15-30 seconds for confirmation
- Transaction Receipt - Get execution result
- Check Status - Verify receipt.status === 1
- Process Events - Extract relevant events from logs
- Record - Save confirmation and results
Comparison: Transaction vs Receipt
Get Transaction provides:
- What was sent
- Transaction parameters
- Sender and recipient
Transaction Receipt provides:
- What happened
- Success or failure
- Actual gas used
- Events emitted
Contract Deployment Receipt
For contract deployments:
{
"contractAddress": "0x1234...", // NEW! Deployed contract
"to": null, // null for deployments
"status": 1,
"logs": [...] // Constructor events
}
Always implement a retry mechanism when checking receipts for recently sent transactions. It may take several seconds for a transaction to be mined and the receipt to become available.
A transaction can be confirmed (has a receipt) but still have failed (status = 0). Always check the status field before assuming success!
Gas used is often significantly less than the gas limit. You only pay for gas actually consumed, not the limit you set.
Best Practices
Always check status:
if (receipt.status !== 1) {
throw new Error("Transaction failed")
}
Wait for confirmations:
- 1 confirmation: Usually safe for low-value
- 3-6 confirmations: Recommended for medium-value
- 12+ confirmations: High-value or critical operations
Store receipts:
- Keep receipts for audit trails
- Log gas used for analytics
- Archive event logs for historical data