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 Answer 1

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;
    }
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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