以太币(Ether) 单位之间的换算就是在数字后边加上 wei
、gwei
或 ether
来实现的,如果后面没有单位,缺省的默认值为 wei
。例如 2 ether == 2000 finney
的逻辑判断值为 true
。
注意:
gwei
在solidity 0.6.11
中添加,因此在0.6.11
之前的版本中不可用。
assert(1 wei == 1);
assert(1 gwei == 1e9);//100,000,000
assert(1 ether == 1e18);//100,000,000,000,000,000
货币单位后缀的的效果相当于乘以10的幂。
注意:从0.7.0开始
finney
和szabo
被移除了。