Skip to Content
dApps
On this page

eth_getTransactionReceipt

Returns the receipt of a transaction by transaction hash. The receipt contains information about the transaction execution including status and logs.


Parameters

IndexTypeDescription
0stringTransaction hash (32 bytes)

Returns

object | null - Receipt object or null if not mined yet

FieldTypeDescription
transactionHashstringTransaction hash
transactionIndexstringIndex in block (hex)
blockHashstringBlock hash
blockNumberstringBlock number (hex)
fromstringSender address
tostringRecipient address
cumulativeGasUsedstringTotal gas used in block up to this tx
gasUsedstringGas used by this tx (hex)
contractAddressstringCreated contract address (if applicable)
logsarrayArray of log objects
logsBloomstringBloom filter for logs
statusstring0x1 (success) or 0x0 (failure)
effectiveGasPricestringActual gas price paid (hex)

Example

const receipt = await window.$onekey.ethereum.request({ method: 'eth_getTransactionReceipt', params: ['0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b'] }) if (receipt) { const success = receipt.status === '0x1' console.log('Transaction', success ? 'succeeded' : 'failed') console.log('Gas used:', parseInt(receipt.gasUsed, 16)) console.log('Logs:', receipt.logs.length) }

Wait for Receipt

async function waitForReceipt(txHash, timeout = 60000) { const start = Date.now() while (Date.now() - start < timeout) { const receipt = await window.$onekey.ethereum.request({ method: 'eth_getTransactionReceipt', params: [txHash] }) if (receipt) { return receipt } await new Promise(r => setTimeout(r, 2000)) } throw new Error('Transaction receipt timeout') } // Usage const txHash = await window.$onekey.ethereum.request({ method: 'eth_sendTransaction', params: [txParams] }) const receipt = await waitForReceipt(txHash) console.log('Transaction status:', receipt.status === '0x1' ? 'Success' : 'Failed')

Parse Contract Events

// Set tokenAddress to the intended ERC-20 contract before parsing its Transfer logs. const transferTopic = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' const transferLogs = receipt.logs.filter( log => log.address.toLowerCase() === tokenAddress.toLowerCase() && log.topics[0] === transferTopic && log.topics.length === 3 ) transferLogs.forEach(log => { const from = '0x' + log.topics[1].slice(26) const to = '0x' + log.topics[2].slice(26) const value = BigInt(log.data).toString() console.log(`Transfer: ${from} -> ${to}: ${value}`) })

Errors

CodeMessageDescription
-32602Invalid paramsInvalid transaction hash

Notes

  • Returns null for pending transactions (not yet mined)
  • status field: 0x1 = success, 0x0 = reverted
  • contractAddress is only present for contract creation transactions
  • Use logs to parse emitted events from the transaction

Check the emitting contract and expected ABI when decoding logs. A matching topic alone does not identify a token, and ERC-721 uses the same Transfer event signature with a different indexed layout.

Last updated on