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
    Unitsin Wei
    wei1 wei
    kwei1000 wei(1e3)
    mwei1e6 wei
    gwei1e9 wei
    szabo1e12 wei
    finney1e15 wei
    Ether1e18 wei

The smallest Unit is wei which is equal to 1 x 10 power 12. the base unit is Etheṛ

Let’s have a denomination for each 1 Ether unit.

Ether Units1 Ether
wei1000000000000000000
szabo1000000
finney1000
ether1

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 UnitsValue
seconds1 Seconds
minutes1 minutes= 60 seconds
hours1 hours= 60 minutes
days1 days=24 hours
weeks1 weeks= 7 days
years1 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.