envoy1084
/
30-Days-of-Solidity
30 Days of Solidity step-by-step guide to learn Smart Contract Development.
WARNING: This repository is currently undergoing updates and revisions to incorporate the latest information and advancements in Solidity programming. Please be advised that the content may not be up-to-date or accurate during this time. We expect the updates to be completed within the next 30 days, and appreciate your patience during this process. Thank you for your understanding.
Contents
- Day 1 - Licenses and Pragma
- Day 2 - Comments
- Day 3 - Initializing Basic Contract
- Day 4 - Variables and Scopes
- Day 5 - Operators
- Day 6 - Types
- Day 7 - Functions
- Day 8 - Loops
- Day 9 - Decision Making
- Day 10 - Arrays
- Day 11 - Array Operations
- Day 12 - Enums
- Day 13 - Structs
- Day 14 - Mappings
- Day 15 - Units
- Day 16 - Require Statement
- Day 17 - Assert Statement
- Day 18 - Revert Statement
- Day 19 - Function Modifiers
- Day 20…
This is Day 15 of 30 in Solidity Series
Today I Learned About Units in Solidity.
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;
}
Top comments (0)