Lesson 12 Doubts #1671
-
ref: https://github.com/PatrickAlphaC/hardhat-erc20-fcc/blob/main/contracts/ManualToken.sol
mapping(address => mapping(address => uint256)) public allowance;
uint8 public decimals = 18;
totalSupply = initialSupply * 10**uint256(decimals); Lets see we put initialSupply = 100, what will be the total supply? // Check for overflows
require(balanceOf[_to] + _value >= balanceOf[_to]); as the above require statement will be logically be always true, then why check, is there any way |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
|
Beta Was this translation helpful? Give feedback.
-
1 and 2:DSA will help in such cases.
Going deeper, that 3 and 4:uint8 public decimals = 18;
totalSupply = initialSupply * 10**uint256(decimals); Refer here for the above: https://github.com/ethereumjs/ethereumjs-units/blob/master/units.json After going through it you can answer it yourself. If not, of course, reply and I will help. But try by yourself first. 5:Stablecoins are cryptocurrencies backed 1:1 to their native currency, for example: $USDT is pegged to the US Dollar. 6:This is an old way to do it (refer SafeMath), as we do not really have to check for overflows in the newer Solidity, it is now done automatically by the compiler. So, omitting wouldn't be harmful here. |
Beta Was this translation helpful? Give feedback.
1 and 2:
DSA will help in such cases.
mapping(address => mapping(address => uint256)) public allowance;
basically maps the address key to themapping(address => uint256)
mapping.Going deeper, that
mapping(address => uint256)
itself has a key which points to a uint256 type -- which here is our allowance.3 and 4:
Refer here for the above: https://github.com/ethereumjs/ethereumjs-units/blob/master/units.json
After going through it you can answer it yourself. If not, of course, reply and I will help. But try by yourself first.
5:
Stablecoins are cryptocurrencies backed 1:1 to their native currency, for example:…