"Warning, Visibility For Constructor Is Ignored"

Hello! This is my code,

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

contract TokenName is ERC20 {
constructor(uint256 initialSupply) abstract ERC20(“TokenName”, “TokenSymbol”) {
_mint(msg.sender, initialSupply);
}
}

I get this error

Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it “abstract” is sufficient. → contracts/Neptune.sol:8:5: | 8 | constructor(uint256 initialSupply) public ERC20(“TokenName”, “TokenSymbol”) { | ^ (Relevant source part starts here and spans across multiple lines).

(I’ve replaced my name/symbol with “TokenName” and “TokenSymbol” as placeholders, my actual project name and .sol file name match up.)

Anyways, I then follow what it says and replace “public” with the word “abstract” and then it sparks this error.

ParserError: Expected ‘{’ but got ‘abstract’ → contracts/TokenName.sol:8:40: | 8 | constructor(uint256 initialSupply) abstract ERC20(“TokenName”, “TokenSymbol”) { | ^^^^^^^^

So, I’m not sure what to do at this point and I’ve looked at some of the links on here and can’t seem to find a very direct answer. If anyone could provide a direct answer it would be greatly appreciated, thank you!

Hi, welcome, :wave:

I think you should remove the abstract or public keyword from every constructor, for more details you can have a look at here: https://docs.soliditylang.org/en/v0.8.4/070-breaking-changes.html?highlight=constructor#how-to-update-your-code

1 Like

Hey! Took out the word, it allowed me to compile the project, now when I attempt to deploy, im met with this error.

creation of TokenName errored: Error encoding arguments: Error: invalid BigNumber string (argument=“value”, value="", code=INVALID_ARGUMENT, version=bignumber/5.1.1)

If you’re able to help that would be much appreciated, thank you!

When you deploy the contract, you should pass a value for the parameter initialSupply, so what did you pass for this value?

Hi! I’ve resorted to importing code instead, seems to have launched the token and works fine. If you’re able to offer additional help, with this set of code here;

pragma solidity ^0.8.0;

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

contract TokenName is ERC20 {
constructor(uint256 initialSupply) public ERC20 (“TokenName”, “TOKEN”){
_mint(msg.sender,initialSupply);
}
}

How would I add my own functions such as a transaction fee that of 10% that is able to burn 3%, send 3% to holders, 3% to liquidity, and 1% to a wallet?

Any help is always appreciated, thank you for the help thus far!