Error "Already Known"
When attempting to broadcast a transaction using the RPC method eth_sendRawTransaction
on Ethereum or other EVM-compatible chains, the blockchain may return an error that states, "already known".
This message indicates that the transaction hash provided already exists in the node’s memory pool (mempool) and has been previously broadcasted.
This error originates from the blockchain.
Common Causes
This error can arise due to several factors:
- Duplicate Transaction Submission: The exact transaction may have been submitted twice, either by code or due to a chain reorganization (forked blocks) that led to a retransmission. You can view forked blocks on the following blockchain explorers:
- Deterministic Signing: In Ethereum or other EVM-compatible chains, signing is deterministic. Thus, signing the same data twice produces the same transaction hash. If a backend system reuses the same parameters (nonce, value, recipient, etc.), the resulting transaction will be identical, leading to the same hash.
- Nonce Conflicts: If
eth_getTransactionCount
is called to retrieve the nonce, it may return a value based on canonical (confirmed) transactions only, not pending ones. This can result in two transactions with the same nonce, causing conflicts.
Steps to Troubleshoot and Resolve
-
Check for Duplicate Submission:
- Review the logs and verify if the transaction has been sent twice. This could happen if an external event triggered a resend, such as a reorg or a retry logic in the code.
- Ensure any retry logic or automated resending mechanisms are configured to detect and handle cases where a transaction is already pending.
-
Handle the Nonce Carefully:
- Automated Nonce Tracking: Be mindful of using
eth_sendTransaction
without explicitly setting the nonce. If you are broadcasting transactions in high volume, the nodes may not be fast enough to calculate the next available and unused nonce value. Ethereum Documentation - Manual Nonce Tracking: If manually managing nonces, check both confirmed and pending transactions. You can retrieve the current nonce for pending transactions by calling
eth_getTransactionCount
with thepending
parameter.
- Automated Nonce Tracking: Be mindful of using
-
Review Signing and Transaction Creation Process:
- Ensure that the code generating and signing transactions is not inadvertently creating duplicates. For example, when using libraries like web3j, check that the same transaction parameters (address, nonce, etc.) aren’t reused without incrementing the nonce.
Good to Know
- Find more about the "
nonce
" HERE. - When using the same "
nonce
" by mistake, you may get an error that states, "transaction underpriced
". Find more about this HERE.
Sources
- Ethereum GitHub:
- Geth GitHub Issues:
- Ethereum StackExchange:
Updated 6 days ago