Skip to content

Instantly share code, notes, and snippets.

@CJ42
Created February 13, 2023 07:36
Show Gist options
  • Select an option

  • Save CJ42/4aefcf66b502f286320a1664a8945eba to your computer and use it in GitHub Desktop.

Select an option

Save CJ42/4aefcf66b502f286320a1664a8945eba to your computer and use it in GitHub Desktop.
Examples of values that cannot be suffixed with ether units
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
contract EtherUnits {
function notWorking() public {
uint256 total;
// TypeError: Hexadecimal numbers cannot be used with unit denominations.
// You can use an expression of the form "0x1234 * 1 day" instead.
uint256 a = 0x05 ether;
// ParserError: Expected ';' but got 'ether'
uint256 b = total ether;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment