{"record":{"id":"49f4db83488d0a8d","repo":"datahaven-xyz/datahaven","slug":"invalidethereumaddress","errorCode":"InvalidEthereumAddress","errorMessage":"InvalidEthereumAddress","messagePattern":"InvalidEthereumAddress","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"operator/pallets/datahaven-native-transfer/src/lib.rs","lineNumber":187,"sourceCode":"        /// - `fee`: The fee to incentivize relayers (in native tokens)\n        #[pallet::call_index(0)]\n        #[pallet::weight(T::WeightInfo::transfer_to_ethereum())]\n        pub fn transfer_to_ethereum(\n            origin: OriginFor<T>,\n            recipient: H160,\n            amount: BalanceOf<T>,\n            fee: BalanceOf<T>,\n        ) -> DispatchResult {\n            let who = ensure_signed(origin)?;\n\n            ensure!(!Paused::<T>::get(), Error::<T>::TransfersDisabled);\n\n            // Get the token ID - fails if not registered\n            let token_id = T::NativeTokenId::get().ok_or(Error::<T>::TokenNotRegistered)?;\n\n            ensure!(amount > Zero::zero(), Error::<T>::InvalidAmount);\n            ensure!(fee > Zero::zero(), Error::<T>::ZeroFee);\n            ensure!(\n                recipient != H160::zero(),\n                Error::<T>::InvalidEthereumAddress\n            );\n\n            // Transfer fee to recipient\n            T::Currency::transfer(&who, &T::FeeRecipient::get(), fee, Preservation::Preserve)?;\n\n            // Lock tokens in the sovereign account\n            Self::lock_tokens(&who, amount)?;\n\n            // Build and send the message\n            let message = Self::build_mint_message(token_id, recipient, amount, fee)?;\n            T::OutboundQueue::validate(&message)\n                .and_then(|ticket| T::OutboundQueue::deliver(ticket))\n                .map_err(|_| Error::<T>::SendMessageFailed)?;\n\n            Self::deposit_event(Event::TokensTransferredToEthereum {\n                from: who,","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/datahaven-xyz/datahaven/blob/edcb13dbbcd3c29489eaa2480a6f60ee4cb1f3ec/operator/pallets/datahaven-native-transfer/src/lib.rs#L169-L205","documentation":"transfer_to_ethereum validates that the recipient H160 is not the zero address (recipient != H160::zero()). Sending bridged funds to the zero address on Ethereum would irrecoverably burn them, so the pallet rejects it with InvalidEthereumAddress.","triggerScenarios":"Calling transfer_to_ethereum with recipient = 0x0000000000000000000000000000000000000000.","commonSituations":"Unset/empty recipient fields defaulting to zero address; encoding bugs producing a zeroed H160; users pasting incomplete addresses.","solutions":["Validate the Ethereum address is a well-formed 20-byte value and not the zero address before submission.","Use checksummed address parsing (e.g. viem's isAddress / getAddress) in the client.","Reject empty or placeholder inputs at the UI layer."],"exampleFix":"// before\nconst recipient = recipientInput ?? '0x0000000000000000000000000000000000000000';\n// after\nimport { isAddress } from 'viem';\nif (!isAddress(recipientInput) || recipientInput === '0x0000000000000000000000000000000000000000') throw new Error('invalid recipient');\nawait api.tx.datahavenNativeTransfer.transferToEthereum(recipientInput, amount, fee);","handlingStrategy":"validation","validationCode":"const ZERO = '0x0000000000000000000000000000000000000000';\nif (!isAddress(recipient) || recipient.toLowerCase() === ZERO) throw new Error('recipient must be a valid non-zero Ethereum address');","typeGuard":"const isValidRecipient = (r) => typeof r === 'string' && /^0x[0-9a-fA-F]{40}$/.test(r) && r !== '0x' + '0'.repeat(40);","tryCatchPattern":"try {\n  await transferToEthereum(recipient, amount, fee);\n} catch (e) {\n  if (String(e).includes('InvalidEthereumAddress')) showFormError('Enter a valid Ethereum address');\n  else throw e;\n}","preventionTips":["Use checksummed address parsing libraries for all address inputs.","Never default recipients to the zero address.","Require explicit user confirmation of the destination address."],"tags":["validation","address","bridge","dispatch-error"],"backgroundTag":"invalid-argument-value","analyzedSha":"edcb13dbbcd3c29489eaa2480a6f60ee4cb1f3ec","analyzedAt":"2026-09-13T19:19:32.206Z","contentChangedAt":"2026-09-13T19:19:32.206Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}