Mint function is not working

i want to add mint function to my token. but its given me error

 Type is not callable
--> si.sol:1002:9:

here is the functions

 function mint(address to, uint256 amount) public onlyOwner {
    _tTotal(to, amount);
}


function _mint(address account, uint256 amount) internal virtual onlyOwner {
    require(account != address(0), "BEP20: mint to the zero address");

    _transfer(address(0), account, amount);

    totalSupply += amount;
    balanceOf[account] += amount;
    emit Transfer(address(0), account, amount);
}

here is the total supply generator

uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000000000  * 10**18;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;

full code https://github.com/coderbang1/mint/tree/main

function mint(address to, uint256 amount) public onlyOwner {
_tTotal(to, amount);
}

Are you sure you wanted to call _tTotal here instead of _mint?

_mint is give me these error…


TypeError: Expression has to be an lvalue.
    --> si.sol:1011:9:
     |
1011 |         totalSupply += amount;
     |         ^^^^^^^^^^^

TypeError: Operator += not compatible with types function () view returns (uint256) and uint256
    --> si.sol:1011:9:
     |
1011 |         totalSupply += amount;
     |         ^^^^^^^^^^^^^^^^^^^^^

TypeError: Indexed expression has to be a type, mapping or array (is function (address) view returns (uint256))
    --> si.sol:1012:9:
     |
1012 |         balanceOf[account]

+=

Did you declare/define that totalSupply variable?

yes…can you plz take a look at the full code?

that code looks like a copy paste from another validated smart contract, I didn’t see that totalSupply variable, only a function with that name.

can you change that?

I can not change that.

good…what can u do?

You have no totalSupply variable only a function that returns _tTotal therefor you cannot += totalSupply because it is function not a variable
Perhaps due to your naming conventions it should be _tTotal += amount;
not totalSupply += amount;

1 Like

Thank you. I will change it and let you know

now this error:

Indexed expression has to be a type, mapping or array (is function (address) view returns (uint256))
–> si.sol:1015:9:
|
1015 | balanceOf[account] += amount;
| ^^^^^^^^^