-
Notifications
You must be signed in to change notification settings - Fork 481
Open
Description
While working with a simple ink! contract that uses env().transfer, I ran into an unexpected error when using small transfer values like 1 or 10:
Contract Reverted! "DecimalPrecisionLoss" "Failed to convert an EVM balance to a native balance."
Minimal Example
#[ink(message)]
pub fn transfer(&mut self, to: H160, value: U256) {
self.env().transfer(to, value);
}Calling this method with value = 1 or 10 triggers the revert, while using a larger amount (e.g., 1_000_000) works fine.
The issue seems to stem from a mismatch between the EVM 18 decimal format (U256) and the Substrate-based chain’s native balance (Tested with ink-node). Smaller values are likely too low to be accurately converted, triggering a DecimalPrecisionLoss error.
DevEx concern
This error is not obvious to developers, especially when testing or writing basic contract logic. How can we improve the DevEx of this?
Metadata
Metadata
Assignees
Labels
No labels