DEV Community

Cover image for Mastering Ether Units: A Guide to Solidity Conversions
Shlok Kumar
Shlok Kumar

Posted on

Mastering Ether Units: A Guide to Solidity Conversions

Ether Units in Solidity are a way to handle and express values in ETH

Ether is the name of the currency that is used in the Ethereum blockchain. It is used to pay for work done in the EVM. A way to do this is to buy gas for ether. This is done as explained in the gas section.

Transactions are paid with ether. Similar to how one dollar is equal to 100 cent, one ether is equal to 1018 wei.


Metric units are used to measure how much ether there is in each type of unit. There is a name for each denomination that is different from the rest (some bear the family name of seminal figures playing a role in the evolution of computer science and cryptoeconomics). You can think of Wei as being the smallest amount of ether that you can get. Below is a list of the denominations and the value in Wei for each one of them. Following a common pattern, ether also refers to a unit of the currency, which is 1e18, or one quintillion Wei. The currency is not called "Ether," as many people think, and it is not a unit called "Ether."


Solidity Program to understand Ether units:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

contract EtherUnits {
    uint public oneWei = 1 wei;
    // 1 wei is equal to 1
    bool public isOneWei = 1 wei == 1;

    uint public oneEther = 1 ether;
    // 1 ether is equal to 10^18 wei
    bool public isOneEther = 1 ether == 1e18; 
Enter fullscreen mode Exit fullscreen mode

All of the following assertions in Solidity will be equivalent to true

assert(1 wei == 1);
assert(1 szabo == 1e12);
assert(1 finney == 1e15);
assert(1 ether == 1e18);
assert(2 ether == 2000 fenny); 
Enter fullscreen mode Exit fullscreen mode

 For more content, follow me on -


Top comments (1)

Sloan, the sloth mascot
Comment deleted