nautechsystems/nautilus_trader · error

Invalid receipt log address

Error message

Invalid receipt log address

What it means

When building a VerifiedReceiptLog, the raw receipt log's string address field is parsed into an alloy Address. If Address::from_str fails, the error is replaced with the generic 'Invalid receipt log address'. This means the address string in the RPC receipt log is not a valid 20-byte Ethereum address encoding.

Source

Thrown at crates/adapters/blockchain/src/rpc/verification.rs:166

}

impl TryFrom<RpcTransactionReceipt> for VerifiedReceipt {
    type Error = anyhow::Error;

    fn try_from(receipt: RpcTransactionReceipt) -> Result<Self, Self::Error> {
        let logs = receipt
            .logs
            .into_iter()
            .map(|log| {
                Ok(VerifiedReceiptLog {
                    removed: log.removed,
                    log_index: parse_optional_quantity(log.log_index.as_deref())?,
                    transaction_index: parse_optional_quantity(log.transaction_index.as_deref())?,
                    transaction_hash: parse_optional_hash(log.transaction_hash.as_deref())?,
                    block_hash: parse_optional_hash(log.block_hash.as_deref())?,
                    block_number: parse_optional_quantity(log.block_number.as_deref())?,
                    address: Address::from_str(&log.address)
                        .map_err(|_| anyhow::anyhow!("Invalid receipt log address"))?,
                    data: Bytes::from_str(&log.data)
                        .map_err(|_| anyhow::anyhow!("Invalid receipt log data"))?,
                    topics: log
                        .topics
                        .iter()
                        .map(|topic| {
                            B256::from_str(topic)
                                .map_err(|_| anyhow::anyhow!("Invalid receipt log topic"))
                        })
                        .collect::<anyhow::Result<_>>()?,
                })
            })
            .collect::<anyhow::Result<_>>()?;
        Ok(Self {
            transaction_hash: receipt.transaction_hash,
            block_hash: receipt.block_hash,
            block_number: receipt.block_number,
            gas_used: receipt.gas_used,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Log/inspect log.address; confirm it is exactly 40 hex characters (20 bytes), e.g. 0x + 40 hex digits.
  2. Validate the address string with Address::from_str before constructing the receipt to get the underlying parse error instead of the generic message.
  3. Fix the data source (RPC provider, indexer, fixture) that is emitting the malformed address.
  4. If addresses may be absent in your data model, handle the optional case upstream rather than passing an empty string.

Example fix

// before
let addr_str = "0x1234"; // truncated
// after
let addr = alloy_primitives::Address::from_str("0x5aaeb6053f3e94c9b9a09f33669435e7ef1beaed")?; // full 20-byte hex
Defensive patterns

Strategy: validation

Validate before calling

fn is_valid_address(s: &str) -> bool {
    let h = s.strip_prefix("0x").unwrap_or(s);
    h.len() == 40 && h.chars().all(|c| c.is_ascii_hexdigit())
}

Try / catch

let address = Address::from_str(&log.address)
    .map_err(|e| anyhow::anyhow!("Invalid receipt log address '{}}}': {e}", log.address))?;

Prevention

When it happens

Trigger: Deserializing/verifying a transaction receipt whose log.address is empty, not hex, wrong length (not 40 hex chars), missing or malformed 0x handling, or otherwise unparseable by alloy's Address parser.

Common situations: Mock/stub receipts in tests with placeholder addresses; a chain or node variant returning addresses in an unexpected casing/encoding; truncated or null address fields from a custom indexer or third-party API; copy-pasted fixtures with typo'd addresses.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/2bbbe66a640df895. Report an issue: GitHub.