PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, September 25, 2022

[FIXED] How to fix "DeclarationError: Identifier not found or not unique"?

 September 25, 2022     blockchain, ethereum, remix, smartcontracts, solidity     No comments   

Issue

I am facing error while calling/deploying my previous contract in new contract "SimpleStorage[] public simplestoragearray;" in line 4 of the code.

// SPDX-License-Identifier: MIT 

pragma_solidity ^0.8.0;

import "./SimpleStorage.sol";

contract StorageFactory{

SimpleStorage[] public simplestoragearray;

function createsimplestoragecontract() public {
    
    SimpleStorage simplestorage = new SimpleStorage();
    simplestoragearray.push(simplestorage);

}
}

Error Message:

from solidity: DeclarationError: Identifier not found or not unique. --> contracts/test contracts/StorageFactory.sol:8:5: | 8 | SimpleStorage[] public simplestoragearray; | ^^^^^^^^^^^^^


Solution

Your contract is probably a differente name than your file.

Change the contract name so it is same as file name it should work.

It is standart practice to name contract file same as contract.

So inside SimpleStorage.sol it should be:

contract SimpleStorage { ... }


Answered By - Kuly14
Answer Checked By - Katrina (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing