hello everyone,
I'm trying to compile a simple contract on VSCODE with Openzeppelin.
this is the source code of the contract -
#####################################
pragma solidity >= 0.6.0 < 0.9.0;
import "D:/ShlavB/TestCon/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "D:/ShlavB/TestCon/node_modules/@openzeppelin/contracts/access/ownable.sol";
contract TestCon is ERC20, Ownable {
address public admin;
uint private limit = 0;
string token_name = 'TestCon';
string token_symbol = 'TTC';
uint256 token_totalSupply = 1000000;
constructor()public ERC20(token_name, token_symbol) {
admin = owner();
transferOwnership(admin);
_mint(admin, token_totalSupply * 10 ** uint256(18));
}
function getLimit() public view returns(uint){
return limit;
}
function setLimit(uint val) public {
require(
msg.sender == admin,
"No access"
);
limit = val;
}
}
###################################################
I'm getting the following error message -
✖️ Compiling contracts with solc 0.8.4 (commit.c7e474f2)
Compilation warnings:
Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
--> contracts\TestCon.sol
Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
--> contracts\TestCon.sol:14:5:
|
14 | constructor()public ERC20(token_name, token_symbol) {
| ^ (Relevant source part starts here and spans across multiple lines).
Cannot convert undefined or null to object
Does anyone have idea why is it happening?
--> contracts\TestCon.sol
Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
--> contracts\TestCon.sol:14:5:
|
14 | constructor()public ERC20(token_name, token_symbol) {
| ^ (Relevant source part starts here and spans across multiple lines).
Cannot convert undefined or null to object
Does anyone have idea why is it happening?
Apr 24, 2021, 1:38 PM
1. Remove public from constructor
2. Add params token_name and token_symbol to your constructor’s input.
2. Add params token_name and token_symbol to your constructor’s input.
Apr 24, 2021, 1:41 PM
Thank you for the fast answer,
should i replace them? i got the in the ERC20 input -
constructor() ERC20(token_name, token_symbol) ?
should i replace them? i got the in the ERC20 input -
constructor() ERC20(token_name, token_symbol) ?
Apr 24, 2021, 1:45 PM
Add the same variables to constructor.
Like:
constructor(string memory token_name, string memory token_symbol)
Like:
constructor(string memory token_name, string memory token_symbol)
Apr 24, 2021, 1:46 PM