Created
February 13, 2023 07:36
-
-
Save CJ42/4aefcf66b502f286320a1664a8945eba to your computer and use it in GitHub Desktop.
Examples of values that cannot be suffixed with ether units
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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