0
pragma solidity ^0.5.8;


contract HelloWorld {

    function test() pure returns (string) {
        return "HelloWorld";
    }

}
1
  • What's the problem with it (perhaps apart from the function not being declared public/private/external/internal)? Commented Aug 20, 2019 at 9:51

1 Answer 1

1

Assuming that you have the right compiler version (use a different one if needed) you are missing a few keywords from the function: public to denote that the function is accessible everywhere and memory to denote that the string is loaded from memory - string parameters have to be loaded from memory.

So the corrected version is:

function test() public pure returns (string memory) {
    return "HelloWorld";
}
2
  • i am sorry do you know how to correct this code for the ^0.5.8 compiler , function balanceOf(address _owner) constant returns(uint256){ return balances[_owner]; } thx
    – YwD
    Commented Aug 20, 2019 at 14:17
  • Please post a new question if you have a new problem Commented Aug 21, 2019 at 4:54

Your Answer

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

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