Units in Solidity
Almost in all the programming languages we must be heard of local, static and global variables. Similar way Solidity also has units and globally available variables. The units are divided into Ether and Time units. Ether is important and used to transfer between accounts and paying transaction fees.
Ether Units:
We need currency to make transactions for good and services, similarly Ether is used to pay for the computational transactions that’s currency of Ethereum virtual machine. It is referred as denomination.

In Ether units, the smallest unit is wei and the largest is ether and they can be converted like dollars and cents. The literal can be with the suffix like wei, finney and szabo. The currency without the postfix is by default taken as smaller unit, Wei.
Here in the following example Etherunits contract is written and executed in Remix IDE. The programs has two functions isOneEther and isOneWei. The isOneWei will return true when 1 wei is equal to 1 literal. And in the same way isOneEther will return true when 1 ether is equal to 1e18 (1 x 1018). The program also display the value of 1 wei and 1 ether.


You can find the unit details in any of the transactions listed in etherscan.io

Time Units
Similar to currency unit the Solidity has time unit to specify seconds, minutes, hours, weeks and days as suffixes. The lower units second. The suffix years is removed in version 0.5.0 due to difficulty of calculation in leap seconds.
In code, it can be referred as,
uint a = 3 minutes // 180 or 3*60
uint b = 2 hours; // 7200 or 2*60*60
uint c = 3 weeks // 1814400 or 3*7*24*60*60
it is also possible to use math operations like + and — symbols with any time unit.
uint date = 1658997083;
uint laterDate = date + 1 days;
uint beforeDate = date — 3 days;
uint prevWeek = date — 1 weeks;
We hope that this helps for better understanding of ether and time unit of solidity. Enjoy reading :) :) :)
New to trading? Try crypto trading bots or copy trading
