Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.52 KB

readme.md

File metadata and controls

52 lines (38 loc) · 1.52 KB

30 Days Of Solidity: Units

Twitter Follow

Author: Vedant Chainani
June, 2022

<< Day 14 | Day 16 >>

Day 15


📔 Day 15

In solidity we can use wei, gwei or ether as a suffix to a literal to be used to convert various ether based denominations. Lowest unit is wei and 1e12 represents 1 x 10^12.

Similar to currency, Solidity has time units where lowest unit is second and we can use seconds, minutes, hours, days and weeks as suffix to denote time.

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

contract MyUnits {
    // 1 wei == 1
    // 1 gwei == 1e9
    // 1 ether == 1e18
    uint256 costOfNFT = 12.5 ether;
    uint256 gasLimit = 3000 wei;

    //1 == 1 seconds
    //1 minutes == 60 seconds
    //1 hours == 60 minutes
    //1 days == 24 hours
    //1 weeks == 7 days

    uint256 durationOfMint = 7 days;
}

<< Day 14 | Day 16 >>