SmartContract decimals and max supply

3.1k views Asked by At

I am new to smartcontracts and I am trying to learn so I need help with one question:

I need the total supply to be 1 trillion 1.000.000.000.000 and I also need the decimals to be only 5

I coded it like this:

uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 100000000 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = "FromSafeMoon";
string private _symbol = "FROMSAFE";
uint8 private _decimals = 5;
uint256 public _taxFee = 1;
uint256 private _previousTaxFee = _taxFee;
uint256 public _liquidityFee = 4;
uint256 private _previousLiquidityFee = _liquidityFee;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
uint256 public _maxTxAmount = 5000000 * 10**6 * 10**9;
uint256 private numTokensSellToAddToLiquidity = 500000 * 10**6 * 10**9;

What I don't understand is if the decimals set to 5 is correct and the max supply is correct to 1 trillion because the blockchain Binance uses this kind of mathematics and I really suck for maths.

Can anyone help me understand that please ? and... Is it correct the 1 trillion supply and the 5 decimals ?

EDIT: When I try to deploy it, I get a warning message about wrong powers, but I know nothing about math-powers

1

There are 1 answers

0
Danushka Adikari On

If you want to use 5 as your decimals It must be,

_tTotal = 100000000 * 10**6 * 10**5 

This is simply 100000000 x 1000000 = 100,000,000,000,000 (Total Supply) In other words with the 5 decimals (10**5) total supply precisely be , 100,000,000,000,000.00000