eth_getTransactionReceipt
Returns the receipt of a transaction by transaction hash, including contract events and execution status.
When to Use This Method
Use eth_getTransactionReceipt
to:
- Confirm Transaction Success - Check if transaction was executed successfully
- Get Contract Events - Access emitted logs and events
- Track Gas Usage - See actual gas consumed
- Monitor Cross-Chain Status - Verify omnichain operations
- Get Contract Address - For contract deployments
Parameters
- Transaction Hash -
DATA
, 32 Bytes- Hash of the transaction
{
"jsonrpc": "2.0",
"method": "eth_getTransactionReceipt",
"params": [
"0xab3e45b76bb6bc87485e190a3d4c8e2e370806e490f2024d62b53a05e0a2a2b0"
],
"id": 1
}
Returns
Receipt object or null
if not found:
status
-0x1
(success) or0x0
(failure)blockHash
- Hash of the blockblockNumber
- Block numbertransactionHash
- Transaction hashtransactionIndex
- Position in blockfrom
- Sender addressto
- Receiver addresscontractAddress
- Created contract address (if applicable)cumulativeGasUsed
- Total gas used in block up to this transactiongasUsed
- Gas used by this transactioneffectiveGasPrice
- Actual gas price paidlogs
- Array of log objectslogsBloom
- Bloom filter for logstype
- Transaction type
Implementation Examples
- cURL
- JavaScript
- Python
curl -X POST https://api-zetachain-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionReceipt",
"params": [
"0xab3e45b76bb6bc87485e190a3d4c8e2e370806e490f2024d62b53a05e0a2a2b0"
],
"id": 1
}'
import { ethers } from 'ethers';
const provider = new ethers.JsonRpcProvider('https://api-zetachain-mainnet.n.dwellir.com/YOUR_API_KEY');
// Get transaction receipt
const receipt = await provider.getTransactionReceipt(
'0xab3e45b76bb6bc87485e190a3d4c8e2e370806e490f2024d62b53a05e0a2a2b0'
);
if (receipt) {
console.log('Status:', receipt.status === 1 ? 'Success' : 'Failed');
console.log('Gas Used:', receipt.gasUsed.toString());
console.log('Block:', receipt.blockNumber);
// Process events
receipt.logs.forEach(log => {
console.log('Event:', log);
});
}
// Monitor transaction confirmation
async function waitForTransaction(txHash, confirmations = 1) {
const receipt = await provider.waitForTransaction(txHash, confirmations);
if (receipt.status === 1) {
console.log('Transaction successful!');
return { success: true, receipt };
} else {
console.log('Transaction failed!');
return { success: false, receipt };
}
}
// Decode cross-chain events
class CrossChainEventDecoder {
decodeReceipt(receipt) {
const crossChainEvents = [];
for (const log of receipt.logs) {
if (this.isCrossChainEvent(log)) {
crossChainEvents.push({
address: log.address,
topics: log.topics,
data: log.data,
decoded: this.decodeEvent(log)
});
}
}
return crossChainEvents;
}
}
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://api-zetachain-mainnet.n.dwellir.com/YOUR_API_KEY'))
# Get transaction receipt
tx_hash = '0xab3e45b76bb6bc87485e190a3d4c8e2e370806e490f2024d62b53a05e0a2a2b0'
receipt = w3.eth.get_transaction_receipt(tx_hash)
if receipt:
print(f"Status: {'Success' if receipt['status'] == 1 else 'Failed'}")
print(f"Gas Used: {receipt['gasUsed']}")
print(f"Block: {receipt['blockNumber']}")
print(f"Logs: {len(receipt['logs'])}")
# Process events
for log in receipt['logs']:
print(f"Event from {log['address']}")
Example Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"status": "0x1",
"blockHash": "0xa957d47df264a31badc3ae823ab19cf626b1b76b013ce3cb5fc9dab3705b415a",
"blockNumber": "0x5daf3b",
"transactionHash": "0xab3e45b76bb6bc87485e190a3d4c8e2e370806e490f2024d62b53a05e0a2a2b0",
"transactionIndex": "0x40",
"from": "0xa7d9ddbe1f17865597fbd27ec712455208b6b76d",
"to": "0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb",
"contractAddress": null,
"cumulativeGasUsed": "0x33bc",
"gasUsed": "0x4dc",
"effectiveGasPrice": "0x4a817c800",
"logs": [
{
"address": "0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000a7d9ddbe1f17865597fbd27ec712455208b6b76d",
"0x000000000000000000000000f28c0498117e19fd0fa85a6feec6114e260cabc9"
],
"data": "0x0000000000000000000000000000000000000000000000000f3dbb76162000",
"blockNumber": "0x5daf3b",
"transactionHash": "0xab3e45b76bb6bc87485e190a3d4c8e2e370806e490f2024d62b53a05e0a2a2b0",
"transactionIndex": "0x40",
"blockHash": "0xa957d47df264a31badc3ae823ab19cf626b1b76b013ce3cb5fc9dab3705b415a",
"logIndex": "0x0",
"removed": false
}
],
"logsBloom": "0x00000000000000000000000000000000...",
"type": "0x2"
}
}
Common Use Cases
Transaction Success Verification
async function verifyTransactionSuccess(txHash) {
const receipt = await provider.getTransactionReceipt(txHash);
if (!receipt) {
return { status: 'pending', message: 'Transaction not yet mined' };
}
if (receipt.status === 1) {
return {
status: 'success',
blockNumber: receipt.blockNumber,
gasUsed: receipt.gasUsed,
effectiveGasPrice: receipt.effectiveGasPrice
};
} else {
return {
status: 'failed',
blockNumber: receipt.blockNumber,
gasUsed: receipt.gasUsed,
reason: 'Transaction reverted'
};
}
}
Event Processing
function processTransactionEvents(receipt) {
const events = [];
for (const log of receipt.logs) {
events.push({
address: log.address,
eventSignature: log.topics[0],
indexed: log.topics.slice(1),
data: log.data,
blockNumber: log.blockNumber,
logIndex: log.logIndex
});
}
return events;
}
Best Practices
- Check receipt status before processing
- Wait for confirmations for important transactions
- Handle null receipts for pending transactions
- Decode logs using contract ABI
- Monitor gas usage for optimization
Related Methods
- eth_getTransactionByHash - Get transaction details
- eth_sendRawTransaction - Send transaction
- eth_getLogs - Query event logs
- eth_getBlockByNumber - Get block details