linera-io/linera-protocol · error
invalid tx hash: {}
Error message
invalid tx hash: {} What it means
The linera-bridge 'generate-deposit-proof' CLI parses the --tx-hash argument with B256::from_str, which requires a 32-byte hex value (64 hex chars, optionally 0x-prefixed). Any other shape fails and is reported with this message including the offending input.
Source
Thrown at linera-bridge/src/main.rs:253
self.max_retries,
self.sqlite_path.as_deref(),
self.evm_poll_interval_ms
.map(std::time::Duration::from_millis),
self.max_log_block_range,
))
.await
}
}
impl GenerateDepositProofOptions {
async fn run(&self) -> Result<()> {
use alloy_primitives::B256;
use linera_bridge::proof::gen::{DepositProofClient, HttpDepositProofClient};
let tx_hash: B256 = self
.tx_hash
.parse()
.map_err(|_| anyhow::anyhow!("invalid tx hash: {}", self.tx_hash))?;
eprintln!("Generating deposit proof for tx {}...", self.tx_hash);
let client = HttpDepositProofClient::new(&self.rpc_url)?;
let proof = client.generate_deposit_proof(tx_hash).await?;
let result = serde_json::json!({
"block_header_rlp": alloy_primitives::hex::encode_prefixed(&proof.block_header_rlp),
"receipt_rlp": alloy_primitives::hex::encode_prefixed(&proof.receipt_rlp),
"proof_nodes": proof.proof_nodes.iter()
.map(alloy_primitives::hex::encode_prefixed)
.collect::<Vec<_>>(),
"tx_index": proof.tx_index,
"log_indices": proof.log_indices,
});
let json_str = serde_json::to_string_pretty(&result)?;
eprintln!("Writing deposit proof to {:?}", self.output);View on GitHub (pinned to 6c226ddcb3)
Solutions
- Pass the full 66-character 0x-prefixed transaction hash (0x + 64 hex chars)
- Trim whitespace/newlines from the variable before invoking the CLI
- Verify the hash on a block explorer for the same network and copy the full transaction hash
Example fix
# before: truncated / wrong-length hash --tx-hash 0x7f3a9d # after: full 32-byte transaction hash --tx-hash 0x7f3a9d2b...full 64 hex chars...
Defensive patterns
Strategy: validation
Validate before calling
fn valid_tx_hash(s: &str) -> bool {
let h = s.trim().strip_prefix("0x").unwrap_or(s.trim());
h.len() == 64 && h.bytes().all(|b| b.is_ascii_hexdigit())
} Type guard
fn parse_tx_hash(s: &str) -> Option<B256> {
s.trim().parse().ok()
} Prevention
- Validate 0x + 64 hex in scripts before invoking the CLI
- Trim whitespace/newlines from hash variables in CI pipelines
- Copy full transaction hashes from explorers, never abbreviated ones
When it happens
Trigger: Running the CLI with a truncated hash (e.g. '0x7f3a'), non-hex characters, embedded whitespace from shell quoting, a block hash instead of a transaction hash, or a hash copied with an ellipsis from an explorer page.
Common situations: Copy-pasting from block explorers that abbreviate hashes; passing the wrong kind of hash (block vs transaction); trailing newline or spaces in scripts/CI variables; hashes from a different chain format.
Related errors
- transaction receipt not found for {tx_hash}
- receipt missing block_hash (pending tx?)
- receipt missing transaction_index
- block not found for hash {block_hash}
- header RLP hash mismatch: computed {computed_hash}, expected
AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22).
Data as JSON: /api/errors/a78d0587474fe67a.
Report an issue: GitHub.