0
pragma solidity ^0.5.8;


contract HelloWorld {

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

}
  • What's the problem with it (perhaps apart from the function not being declared public/private/external/internal)? – goodvibration Aug 20 at 9:51
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";
}
  • thank you so much – YwD Aug 20 at 13:27
  • 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 Aug 20 at 14:17
  • Please post a new question if you have a new problem – Lauri Peltonen Aug 21 at 4:54

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.