Why does token have balance of 000000.1 instead of 10,000

This is my simple code just learning the process. Why when i launch the code does my wallet only receive 000000.1 instead of 10,000,000 what am i doing wrong thanks in advance

pragma solidity ^0.5.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/token/ERC20/ERC20Detailed.sol";

contract $420 is ERC20, ERC20Detailed {

    constructor () public ERC20Detailed("$420", "420", 18) {
        _mint(msg.sender, 10000000 * (10 ** uint256(decimals())));
    }
}
1 Like

Hi @apex_legend,

I just deployed in Remix and it shows the balance and total supply as I would expect:

image

Unless you have a specific need to use Solidity 0.5, I suggest looking at OpenZeppelin Contracts Wizard to generate an ERC20: https://zpl.in/wizard

1 Like

Ive tried every zeppelin link and it will never compile this is the only way it works for me. So you re able tp get 10,000,000 coins sent t your wallet if you were to deploy? The code is correct?

Will this zeppelin code not function properly if I were to deploy it on BSC. Want a personal coin in my wallet for fun just trying to build it. 10,000,000. wins was the goal. At first I ended up with .0000001 coming to my wallet now I cant even link need more gas. But don’t want to pay again if it will do the same. Thanks in advance

Solidity is not dealing with decimals, This is usually done in the front end.

In solidity all amount are in Wei with no decimals.

1 ETHER = 1000000000000000000

it has 18 decimals places. so if the frontend take a number like 10 000
it has to be passed as wei so 10 000 = 10 000 000 000 000 000 000 000 Wei

10 000 000 in WEI would give you 0.000000000010000000 ETHER

It looks like you are not using the right amount of decimals places.

I see you pass 18 to the function but then use uint256 decimals?? What value is assigned to decimals?

1 Like