decimals (optional)

Fixed-point numbers aren't supported in Solidity or inside the EVM, so a different method of representing them has to be used. If we want our contract to be able to represent fractional tokens, then we need a way to represent them as fixed-point numbers. To do this, we use a scaling factor, given by decimals, which describes the number of places after the decimal point that our fractional tokens can be represented to.

For example, if we want to be able to represent 4.5001 tokens, then we require a decimal value of at least 4. In general, the use of 18 is the de facto standard:

uint8 public decimals;

For the sake of simplicity, our implementation will only deal with whole tokens, so we won't implement the decimals variable in our contract.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset