How can a transaction have a hash before it is confirmed?
Why does a transaction hash exist before it is confirmed? The wallet hashes the signed transaction locally, and a block later records that same hash.
The ChainBrief Editors
An Ethereum transaction can have a hash before it is confirmed because the wallet calculates the Keccak-256 hash of the signed, serialized transaction as soon as signing is complete; a block later records that same hash.
A pending hash identifies the signed transaction, not proof that a block has included it.
- Input: the signed transaction fields and signature.
- Process: the wallet serializes and hashes them with Keccak-256.
- Result: a hash appears before sending and can later be matched to the transaction in a block.
Signing fixes the transaction’s nonce, fee fields, recipient, data and signature. The wallet can serialize those values and hash them without waiting for a node, builder or block. Once the signed data is fixed, the hash is fixed too.
Private routing changes where a signed transaction is sent, not how its hash is made. A swap sent through Flashbots Protect can use sandwich attack protection along the way, while the wallet still calculates the hash locally.
What the pending hash identifies
The hash is a fingerprint of the signed transaction’s serialized data. It gives wallets and explorers a compact identifier for that particular signed version. Changing a signed field produces different data and therefore a different hash.
Take a swap you sign and send through Flashbots Protect. Your wallet can show its hash immediately because it already has the signed transaction. Before a builder includes that private transaction in a block, a public explorer such as Etherscan may show no matching transaction. If a builder includes it, the block contains the same signed transaction, and the hash shown in the block matches the one your wallet gave you.
The public or private route does not create a different hash. The route affects where the transaction is sent and who can see it before inclusion; the hash comes from the signed transaction itself.
Why a replacement has a different hash
A speed-up or cancellation is a new transaction signed with the same nonce as the pending one. A speed-up changes fee fields; a cancellation typically changes the recipient and data to make the replacement a self-directed transaction. Because at least one signed field changes, the replacement has a new serialized form and a new hash.
Suppose your swap has nonce 12 and hash A. You submit a speed-up with nonce 12, higher fees and hash B. If the replacement is included first, nonce 12 has been used, so the original version may never confirm. The intended action may still complete through hash B, even while hash A remains unconfirmed.
That is why a hash alone can be misleading when you are checking whether an action succeeded. Track the sending address and nonce as well as the hash. Look for which transaction using that nonce was included, and check its recipient and data to see whether it was the swap, a replacement or a cancellation.
When a pending hash seems stuck, compare the transactions for that address and nonce. This shows whether the original is still pending or a replacement carried out the action.