{"record":{"id":"4489d79423b2cc3f","repo":"datahaven-xyz/datahaven","slug":"invalidamount","errorCode":"InvalidAmount","errorMessage":"InvalidAmount","messagePattern":"InvalidAmount","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"operator/pallets/datahaven-native-transfer/src/lib.rs","lineNumber":185,"sourceCode":"        /// - `recipient`: The Ethereum address to receive the tokens\n        /// - `amount`: The amount of tokens to transfer\n        /// - `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","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/datahaven-xyz/datahaven/blob/edcb13dbbcd3c29489eaa2480a6f60ee4cb1f3ec/operator/pallets/datahaven-native-transfer/src/lib.rs#L167-L203","documentation":"transfer_to_ethereum requires a strictly positive transfer amount (amount > Zero::zero() via Zero from sp_arithmetic traits). Zero or negative-overflowing amounts are rejected with InvalidAmount because transferring nothing would be a no-op/fee-only drain and breaks invariants downstream.","triggerScenarios":"Calling transfer_to_ethereum with amount == 0 (or any value failing amount > 0), even if the fee is positive and the address is valid.","commonSituations":"UI defaults leaving amount unset (0) and submitting anyway; automated scripts with empty balance inputs; decimals/unit confusion producing a rounded-down amount of 0.","solutions":["Ensure amount > 0 before submitting the extrinsic.","Validate the user input in the UI/script and block submission when the parsed amount (after decimal adjustment) is 0.","If the amount became 0 due to rounding, fix the decimals conversion."],"exampleFix":"// before\nawait api.tx.datahavenNativeTransfer.transferToEthereum(recipient, 0n, fee);\n// after\nif (amount <= 0n) throw new Error('amount must be greater than zero');\nawait api.tx.datahavenNativeTransfer.transferToEthereum(recipient, amount, fee);","handlingStrategy":"validation","validationCode":"function validateTransfer(amount, fee, recipient) {\n  if (amount <= 0n) throw new Error('amount must be greater than zero');\n  if (fee <= 0n) throw new Error('fee must be greater than zero');\n  if (recipient === '0x' + '00'.repeat(20)) throw new Error('recipient is zero address');\n}","typeGuard":"const isValidAmount = (amount) => typeof amount === 'bigint' && amount > 0n;","tryCatchPattern":"try {\n  await transferToEthereum(recipient, amount, fee);\n} catch (e) {\n  if (String(e).includes('InvalidAmount')) showFormError('Amount must be greater than 0');\n  else throw e;\n}","preventionTips":["Validate parsed amounts after decimal conversion, before submission.","Disable submit buttons while the amount input is empty or zero.","Unit-test decimal conversion for tokens with different decimals."],"tags":["validation","bridge","substrate","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"}