0

I'm deploying a very standard openzeppelin ERC20 contract with the following code:

pragma solidity ^0.6.0;

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

contract ERC20FixedSupply is ERC20 {
    constructor() public ERC20("Fixed", "FIX") {
        _mint(msg.sender, 1000);
    }
}

This code is present at openzeppelin's own documentation here: https://docs.openzeppelin.com/contracts/3.x/erc20-supply

My steps: installed truffle, installed openzeppelin, created the file with the above code, flattened with truffle flattener and deployed using remix with metamask (Kovan network). Deployment successful and I get the contract address fine, but when I try to check the sender address wallet for the token, it's empty.

Here's what I see on metamask after adding the token:

enter image description here

Token page shows this: https://kovan.etherscan.io/tokens?q=0x87B62aAcEc6d304c26d4514ccD9Cb4F6Bc3bc114

What am I missing?

1

Your deployment seems to be incorrect. The contract you deployed has only an empty fallback function that reverts: https://kovan.etherscan.io/bytecode-decompiler?a=0x87B62aAcEc6d304c26d4514ccD9Cb4F6Bc3bc114.

My guess is that in Remix you clicked on ERC20 (or some other incorrect contract) instead of ERC20FixedSupply.

pragma solidity 0.6.9;

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

contract ERC20FixedSupply is ERC20 {
    constructor() public ERC20("Fixed", "FIX") {
        _mint(msg.sender, 1000);
    }
}

This code works for me in Remix deployments: https://kovan.etherscan.io/tx/0xd7a047e2921dc43d486a97a9b1dedb7fe0f2c705c347f7b807d80c1ef8e2754e.

Make sure you select the correct contract inside Remix:

enter image description here

| improve this answer | |
  • I moved the whole flattened contract to remix.It's a single file – raphadko Jun 10 at 4:02
  • You're right. The new solidity visuals got me confused. – raphadko Jun 10 at 4:08
  • @raphadko Great. I also just added an updated answer with importing directly from Github. That makes it easy to test stuff in Remix. – Markus - soliditydeveloper.com Jun 10 at 4:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.