Deployed ERC777 token, but the balance shown in MetaMask is zero, although initial supply is set to 12000000

hi I just deployed my ERC777 token, with an initial supply of 12000000,
a metamask, (for address[0]), the token has 0 value.

however, under truffle console,

let instance = await PhillipsToken.deployed()
instance.totalSupply(), it showed
BN {
  negative: 0,
  words: [12000000,
  length: 1,
  red: null
}

under instance.balanceOf(address[0])
it showed

BN {
   negative: 0,
   words: [12000000,
   length: 1,
   red: null
}

my code:

import "@openzeppelin/contracts/token/ERC777/ERC777.sol";

contract PhillipsToken is ERC777 {
  uint256 public constant INITIAL_SUPPLY = 12000000;

  constructor () public ERC777("PhillipsToken", "PT", new address[](0)) {
    //_mint(msg.sender,12000 * 10 **2, "", "")_mint(msg.sender,12000 * 10 **2, "", "");;
    _mint(msg.sender,INITIAL_SUPPLY, "", "");


  }

}

why it is zero value at metamask?

1 Like

Hi @stepheniecvc,

Your contract is minting tokens to the deployer of the contract.

For a more readable value, you can do (await instance.balanceOf(address)).toString()

I assume MetaMask is using either a different address or network.

I suggest you check that MetaMask is set to the same network and address that you deployed to.

hi i entered instance.balanceOf(address).toString() it returns [Object Promise]

i run ganache-cli first, then with the mnemonic i log in to metamask… it is under local host: 8545… So the network and address are correct.
I unbox another truffle tutorialToken and deploy to 8545 too… and i am able to see initial supply of 12000000 on metamask for this tutorialToken. Just wonder why this ERC777 token has zero value.

my code:

1 Like

hi i tested with ERC20, and there are initial supply of 12000000, but with ERC777, the initial supply is 0 at metamask.
Just wondering why…

1 Like

Hi @stepheniecvc,

I am sorry that you are still having issues with this.
Apologies, I hadn’t picked up on how small your initial supply was.

MetaMask displays your tokens, it is just that your supply is really small.

I installed truffle locally (I assume you have it installed globally) and show the display

$ npx truffle console
truffle(development)> token = await PhillipsToken.deployed()
undefined
truffle(development)> (await token.balanceOf(accounts[0])).toString()
'12000000'
truffle(development)> (await token.decimals()).toString()
'18'

12000000 with 18 decimals is 0.000000000012 PT

You should increase your initial supply. The following is only 12 PT

uint256 public constant INITIAL_SUPPLY = 12000000000000000000;

I suggest reading A Note on decimals


A Promise is being returned, we can await the result:

truffle(development)> (await token.balanceOf(accounts[0])).toString()
'12000000'

hi i changed the initial supply and able to see the value at metamask now… thank you so much for your help…

1 Like