Better Programming

Advice for programmers.

Follow publication

Member-only story

Solidity Tutorial: All About Ether Units

Jean Cvllr
Better Programming
Published in
8 min readFeb 13, 2023
photo by Sufyan on Unsplash

In this article, we will learn the basics of Ether Units in Solidity. We will look at how to specify ether denominations like wei , gwei and ether and the different options available for declaring values suffixed with one of these Ether denominations.

Table of Contents

Introduction to Ethers Currency Units

Ethers Units Available in Solidity

Allowed Values for Ether Units

Expressions With Ethers Units

Specifying Amounts With Native Token Transfers Between Contracts

Introduction to Ethers Currency Units

Transactions in Ethereum are paid with Ether.

Ether units represent value, such as the amount of money transferred between accounts or the transaction cost.

Like many other cryptocurrencies, ether can be divided into smaller units of value. Similar to how one dollar is equal to 100 cents, one ether is equal to 10¹⁸ wei.

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

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…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Jean Cvllr
Jean Cvllr

Written by Jean Cvllr

Smart Contract engineer at @LUKSO. Full Stack Developer. https://github.com/CJ42

Write a response