I am kind of new at coding smart contracts. For the past week I have been going completely insane trying to set a price for a token.
Token has 2 decimals and I want the cost to be 0.001 ETH. No matter what I do is working. I have googled and read forums and seen people having the same problem, but I have never seen anyone getting a straight answer. So please don’t just tell me to google it, because I have.
The contract uses rate
// How many token units a buyer gets per wei.
// The rate is the conversion between wei and the smallest and indivisible token unit.
// So, if you are using a rate of 1 with a ERC20Detailed token with 3 decimals called TOK
// 1 wei will give you 1 unit, or 0.001 TOK.
uint256 private _rate;
But if I set the rate in wei I’m getting several billion tokens for 0.001 ETH. I have tried things like setting the price in TBNB but that isn’t accepted. I have tried everything in SafeMath, and I have tried everything I can find in this forum and in docs.
Please don’t answer by telling me to learn som new math I never even heard about. I just want the answer, and then I can figure it out later.