2

I verified and deployed a token contract using remix. The totalsupply displays correctly 80000000000 but at etherscan it displays the totalsupply as 0.0000000008.

Summary [ERC-20] Total Supply: 0.00000011 WIMT ($0.00) Price: $0.0000 @ 0.000000 Eth

here is the link https://etherscan.io/token/0x258c6b5e54565a20d925c4b9cdbd97239e3ac3bf

but at etherscan here it displays correctly

We found a Contract With ERC-20 Token Transfer Events

Token 0x258c6b5e54565a20d925c4b9cdbd97239e3ac3bf On-chain Token Attributes Check Result: Total Supply = 110000000000 Name = WIMT Symbol = WIMT Decimals = 18 ERC-165 Interface = {Not Available} Implements ERC-721 = No

here is the link https://etherscan.io/tokens?q=0x258c6b5e54565a20d925c4b9cdbd97239e3ac3bf

How do i correct this without redeploying the contract? Thank for your help.

1 Answers1

1

This is happening because of this line : totalSupply = _totalSupply;

You forgot to multiple it with the decimals. Changing it to totalSupply = _totalSupply * (10 ** uint256(decimals)) can make it as per the requirement.

You can see an example here: https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/examples/SimpleToken.sol

I don't think that there is any way to improve it with redeploying the contract.

Aniket
  • 3,545
  • 2
  • 20
  • 42
  • Thank you for your response. Why is it when I minted 3000000000 the totalsupply became 0.00000011? Why is the mint function not being multiplied by (10*unint256(decimals))? – Bernard Sibanda Nov 22 '18 at 07:06
  • Minted tokens are added in total supply. So your total supply is (80000000000 + 30000000000) * 10^(-18) as etherscan assumes that you have multiplied 10^18 in your value – Aniket Nov 22 '18 at 07:17
  • Thanks. But it fixed only the totalsupply. The totalsupply is displaying correctly. The mint and the transfer functions show 0.00000... decimals and I note OpenZeppelin is version 0.4.24 and I am using version 0.4.23 – Bernard Sibanda Nov 22 '18 at 07:41
  • Version change doesn't matter a lot. Each function of ERC20 token works same with decimals as totalSupply. Decimals play a great role in displaying token values on screens. Is everything clear now? – Aniket Nov 22 '18 at 08:06
  • Thanks a lot. I added decimals on other functions and an error about gas limit start showing. I then went all over open zeppelin. i have compile tested may token smart contracts. Each smart contract comes up with different errors. works one part and fails elsewhere. Is remix a good IDE? – Bernard Sibanda Nov 22 '18 at 16:55
  • A work around was to use older version code solidity 0.4.21, simplified it and add features I wanted. It works now. – Bernard Sibanda Nov 27 '18 at 04:57