I´ve spent a couple weeks try to understanding what was heppening. The same solidity code worked great in REMIX but not in Truffle/Ganache. Let´s me explain. I wrote a code bases on Openzeppelin, but it isn´t the same. I changed variables, names, functions. I kept variable as private and I used public functions to access them, I think is a kind of Ethereum propposal. So I had the abstract contract below, just inheritance and constructor is necessary to solve the problem.
contract ERC20 is Context, IERC20, IERC20Metadata, IPTK{ string private name_; string private symbol_; uint8 private decimals_; uint8 private withdrawnDaily_; uint256 private totalSupply_; mapping(address => uint256) private withdraw_; mapping(address => uint256) private balances_; mapping(address => mapping (address => uint256)) private allowed_; constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _totalSupplyMinted, uint8 _withdrawnDaily) { name_ = _name; symbol_ = _symbol; decimals_ = _decimals; totalSupply_ = _totalSupplyMinted; withdrawnDaily_ = _withdrawnDaily; } Then I create a contract based on that ERC20.
pragma solidity ^0.8.4; import "./tokens/ERC20.sol"; contract Sample3 is ERC20 { constructor() ERC20("Sample3", "SP3", 18, 58000000000, 1) { } } As I told, in Remix it works great. The ERC20 initializes all private variables with right values, but when use truffle/ganache I got the problem. The values are inicializates with wrong numbers as you can see...
After many and many tests I found out that the problem happened with all uint´s variables. Example, uint8 (decimals_ variable) works great with numbers until 12, after that then doesn´t matter with number iss passed, it will keep 12 as a maximun value. Something similar occurs with uint256 (totalSupply_ variable) and I guess with all uint types.
Does anyone has faced something like that? What could be happening?
