Loading...
Unit | wei value | wei | ether value |
wei | 1 wei | 1 | 10^-18 ETH |
kwei | 10^3 wei | 1,000 | 10^-15 ETH |
mwei | 10^6 wei | 1,000,000 | 10^-12 ETH |
gwei | 10^9 wei | 1,000,000,000 | 10^-9 ETH |
microether | 10^12 wei | 1,000,000,000,000 | 10^-6 ETH |
milliether | 10^15 wei | 1,000,000,000,000,000 | 10^-3 ETH |
ether | 10^18 wei | 1,000,000,000,000,000,000 | 1 ETH |
Let's create some solidity functions which can convert gwei,wei to ether & vice versa
Actually it's preety simple; just a matter of some basic codes
pragma solidity ^0.8.3;
contract task1 {
function etherToWei(uint valueEther) public returns (uint)
{
return valueEther*(10**18);
}
function weiToEther(uint valueWei) public returns (uint)
{
return valueWei/(10**18);
}
function etherToGWei(uint valueEther) public returns (uint)
{
return valueEther*(10**9);
}
function gweiToEther(uint valueGwei) public returns (uint)
{
return valueGwei/(10**18);
}
}
For many more exciting tutorials keep following my username @BlockTalks_Raj
!!!!!HAPPY LEARNING!!!!!