Created
August 14, 2023 07:25
-
-
Save Ifeanyi-Ani/eb9b8a36dcb752ba383c33251e154289 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.9+commit.e5eed63a.js&optimize=false&runs=200&gist=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.9; | |
contract EtherConverter { | |
uint256 public weiFactor = 10**18; // Conversion factor from ether to wei | |
uint256 public gweiFactor = 10**9; // Conversion factor from ether to gwei | |
function etherToWei(uint256 _etherValue) public view returns (uint256) { | |
return _etherValue * weiFactor; | |
} | |
function etherToEther(uint256 _etherValue) public view returns (uint256) { | |
return _etherValue; | |
} | |
function etherToGwei(uint256 _etherValue) public view returns (uint256) { | |
return _etherValue * gweiFactor; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Primitive Data Types in Solidity
Challenge
Write a smart contract that takes some ether from the user. Find out its value in units of:
wei
ether
gwei