Hi, I want to use the Reflect Token and want to use a burn mechanism within the contract until I reached a certain amount of total supply without effecting the users balance
I am using following function for that:
function burn(uint amount) external {
require(_tTotal > 3 * 10**8);
_tTotal -= _tFeeTotal;
_tTotal -= amount;
}
If I check the totalSupply then it is reducing the totalSupply. Can someone agree that's the right way?
I want to add the funciton within each transaction which funciton is it? tranfer() or tranferFrom()?
Full Code:
contract REFLECT is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
//10 000 000 000 000
uint256 _tTotal = 10 * 10**12;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'reflect.finance';
string private _symbol = 'RFI';
uint8 private _decimals = 18;
constructor () public {
_rOwned[_msgSender()] = _rTotal;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function burn(uint amount) external {
require(_tTotal > 3 * 10**8);
_tTotal -= _tFeeTotal;
_tTotal -= amount;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
}