Wrapping my head around totalSupply
, decimals
, wei
, and ether
is getting me very confused.
For the purposes of education, I'm trying to make an ERC20 token contract that is capped at only ONE token. My understanding is that, since Solidity doesn't deal with floating point numbers, by setting my decimals
to 18, I actually have 1e18 "parts" to this "one token" of mine.
Please correct me if my understanding is wrong. But I'm going to keep going.
So I've been trying to follow this tutorial and it makes use of:
- A token contract that inherits from
MintableToken
, and; - A crowdsale contract that inherits from
TimedCrowdsale
andMintedCrowdsale
.
In order to change this to a capped supply token, I just made the token contract inherit from CappedToken
instead, added the necessary constructor method, and initialized the cap amount on deployment.
The crowdsale contract takes a rate
value, which I assume is how many tokens to return to the user for 1 wei
.
There are basically 3 parameters at this point:
decimals
=18
rate
=1
cap
=1e18
I'm a bit confused at this point because I keep getting cryptic reverts when I try to send in 1 wei
. Shouldn't 1 wei
buy me 1 of my coins?