1

I am getting the following error while complining DeclarationError:

Identifier not found or not unique. unit storedData;

   pragma solidity ^0.4.0;
//pragma solidity >=0.7.0 <0.9.0; 
contract SimpleStorage {
    unit storedData;
    
    
    function set(unit x) public {
         storedData = x;
    }
    
    function get() constant public returns (unit) { 
         return storedData;
    }
    
    function increment (unit n) public {
        storedData = storedData + n;
        return;
    }
0

Your code has typo in it. In solidity we use unit (unsigned integer) not unit

here is the working version of your code

pragma solidity ^0.4.0;

contract SimpleStorage {
    uint storedData;
    
    
    function set(uint x) public {
         storedData = x;
    }
    
    function get() constant public returns (uint) { 
         return storedData;
    }
    
    function increment (uint n) public {
        storedData = storedData + n;
        return;
    }
    
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.