'running into decleration error in solidity course
just started a solidity coding course and ran into this issue with this code:
//SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
import "./simplestorage.sol";
``
contract StorageFactory {
function createsimplestoragecontract() public {
simplestorage _simplestorage = new simplestorage();
}
}
I'm running into this error: DeclarationError: Identifier not found or not unique. --> contracts/storageFactory.sol:9:9: | 9 | simplestorage _simplestorage = new simplestorage(); | ^^^^^^^^^^^^^
Solution 1:[1]
The following code worked fine for me.
//SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
import "./1_Storage.sol";
contract StorageFactory {
function createsimplestoragecontract() public {
Storage _simplestorage = new Storage();
}
}
Did you check if the name of the contract in simplestorage.sol is "simplestorage"? Usually is Pascal case (not mandatory, but good practice), something like SimpleStorage. Be aware about this. Your error probably is about lowercase instead of uppercase.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | João Paulo Morais |