In Solidity, We have literal numbers that can be suffixed with units.
What is a Unit? It is a denomination in blockchain cryptocurrency used for computational process of EVM.
There are different types of units
- Ether Units
- Time Units
Ether or Currency Units solidty
Ether Units are currency denominations of an Ether
unit.
The number can be suffixed with Ether Units for denominations of Ether units.
- Wei
- kwei
- Finney
- szabo
- ether
Units in Wei wei 1 wei kwei 1000 wei(1e3) mwei 1e6 wei gwei 1e9 wei szabo 1e12 wei finney 1e15 wei Ether 1e18 wei
The smallest Unit is wei
which is equal to 1 x 10 power 12.
the base unit is Ether
̣
Let’s have a denomination for each 1 Ether unit.
Ether Units | 1 Ether |
---|---|
wei | 1000000000000000000 |
szabo | 1000000 |
finney | 1000 |
ether | 1 |
Here is an example
// true condition
if(1 wei == 1){
// true code
}
Time Units
In Solidity, time-based data are represented in Time Units. The lowest unit is 1 Second.
Numbers are suffixed with the below types to represent time
seconds
minutes
hours
days
weeks
years
Time Units | Value |
---|---|
seconds | 1 Seconds |
minutes | 1 minutes= 60 seconds |
hours | 1 hours= 60 minutes |
days | 1 days=24 hours |
weeks | 1 weeks= 7 days |
years | 1 years=365 days |
What is the default unit in Solidity?
Default unit in solidity is wei
. If amount does not include any suffix, Then wei is default.