With the introduction of Solc 0.5.X , parameter memory locations for arrays (and strings/bytes) must be made explicit. For external functions, this memory location is required to be specified as calldata (as per docs).

My question is, how to convert the following function to be 0.5.X compatible and access the properties from within the function body. In addition, what changes (if any) will this have to how we call the method and pass the args?


function accessTheString(string _uri) 
external {        
    contractString = _uri;


function accessTheString(string calldata) 
external {        
    // check for && access the string
  • Have you tried it after just putting the memory location i.e. calldata and leaving rest as it is?
    – Aniket
    Dec 4, 2018 at 8:09
  • @A.K. I have not. The variable is undeclared so how would the contract know which prop to access? Setting string calldata _uri in func args results in compilation error (unexpected token)
    – alsco77
    Dec 4, 2018 at 8:11
  • If you add calldata, you have to update solidity version in pragma as 0.5.0 and need to use 0.5.0 compiler
    – Aniket
    Dec 4, 2018 at 8:28
  • @A.K. Yes I know, this is why I am asking the question
    – alsco77
    Dec 4, 2018 at 8:30

1 Answer 1


The format is

function accessTheString(string calldata _uri) external{        
    string memory contractString= _uri;

Now, I think you made a mistake while calling the function by without passing string between " ". You have to call function accessTheString, by passing a string enclosed in " " ex: accessTheString("hello");

I tested this in remix, and its working

  • Hah.. my problem was that I was using solium linter to lint my contracts from vscode. The release was 5 months ago so presumably they dont support 0.5.x yet. D'oh
    – alsco77
    Dec 5, 2018 at 1: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.