0

i am new to solidity....i was following a tutorial but this error DeclarationError: Identifier not found or not unique. --> MyContract.sol:9:27: | 9 | function get() public views returns(string) { | ^^^^^

the code i tried to compile is

pragma solidity ^0.8.1;


contract MyContract {

string value;


function get() public views returns(string) {
    
     return value;
}


}

can someone tell me why thanks

0
1

Beside of typo in function modifier view you'll require data location provided for string return type

pragma solidity ^0.8.1;


contract MyContract {

    string value;
    
    function get() public view returns(string memory) {
        return value;
    }
}
1
  • yes that worked. Thanks
    – user71717
    May 1 at 15:42

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.