Solidity: Declaration Error: identifier not found or not unique. mapping(string=> team) teams; ^_ _^

Viewed 310

This is my first time to write a computer programming language and it's a smart contract.

After finish, I pressed compile, and it shows the following error: DeclarationError: Identifier not found or not unique. mapping(string=> team) teams;

^_ _^

Please anyone help me to find out what is the problem? My smart contract as below:


// spdx-license-identifier: MIT
pragma solidity ^0.7.0;

contract Database {
   
 struct Team {
        string engineer;
        mapping (string=>uint) numbers;
    }

    mapping(string=>team) teams;

    function addTeams(string calldata teamName, string calldata engineer) public {
        Team storage team = teams [teamName];
        team.engineer = engineer;
    }

    function addDrawingNumber(string calldata teamName, string calldata engineerName, uint number) public {
        Team storage team = teams [teamName];
        team.numbers[engineerName] = number;
    }
    
    function getDrawingNumber(string calldata teamName, string calldata engineerName) public view returns (uint) {
        Team storage team = teams [teamName];
        return team.numbers[engineerName]
   ; }
}
1 Answers

Solidity is a case-sensitive language. You have defined a struct type Team (capital T) - but in the mapping you're trying to use a type team (lowercase t), which is not defined.

Solution: Unify the case sensitivity.

struct Team {
    string engineer;
    mapping (string=>uint) numbers;
}

mapping(string=>Team) teams;
Related