0

dear Ethereum community,

I have this problem upgrading a contract from 0.4.19 to ^0.6.0:

    function someFunction(
            uint256 initialSupply,
            string memory contractName,
            string memory tokenSymbol,
            uint256 contractHoldTime,
            uint256 contractHoldMax,
            uint256 contractMaxSupply,
            address contractOwner


        ) public {

        totalSupply = initialSupply; 
        name = contractName;            
        symbol = tokenSymbol;        
        holdTime = contractHoldTime;
        holdMax = contractHoldMax;
        maxSupply = contractMaxSupply;
        owner = contractOwner; 
        balanceOf[contractOwner] = balanceOf[contractOwner].add(totalSupply);
        }

in the last line balanceOf... Indexed expression has to be a type, mapping or array (is function (address) view returns (uint256))

waiting your reply...

Thanks

  • How did you define balanceOf? – Ismael May 17 at 1:15
  • it inherits from an ERC20 with balanceOf function: function balanceOf(address owner) public view returns (uint256 balance) { return balances[owner]; } – Ecofintech May 17 at 1:25
  • Im chaing the whole structure. Adding syntac and parent libraries from OpenZeppelin. maybe I can solve the issue in a while... – Ecofintech May 17 at 1:41
0

The error means you are trying to use balanceOf as it were a mapping but it is defined as a function instead.

For OpenZeppelin 3.0 if you inherit from ERC20.sol the correct approach to modify a balance is to call _mint():

_mint(contractOwner, totalSupply);
| improve this answer | |

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.