i have erc20 token with 18 decimal, the problem is if i want to transfer 100k token, the javascript can't handle that, because there will lot of 0.
so in smart contract i override all the transfer function into this
function transfer(address _toadr, uint256 _amount) override public returns (bool) {
uint transferedAmount = _amount*10**18;
uint balance =address(msg.sender).balance *10**18;
require(balance >= transferedAmount);
uint256 _teamFee = (transferedAmount / 100) * teamFee;
uint256 _marketingFee = (transferedAmount / 100) * marketingFee;
uint256 _rewardFee = (transferedAmount / 100) * rewardFee;
uint256 _finalAmount = transferedAmount-(_teamFee+_marketingFee+_rewardFee);
_transfer(msg.sender,team,_teamFee);
_transfer(msg.sender,marketing,_marketingFee);
_transfer(msg.sender,rewardpool,_rewardFee);
_transfer(msg.sender,_toadr,_finalAmount);
return true;
}
is this safe to do? or is there a best practice for this?
i heard we can use some utils from web3.js, but i didn't find a way to compare 2 value if i use web3.js utils.