Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

253
Views
Solidity Js, on function get i get an error as "TypeError: Data location must be "memory" or "calldata" for return parameter in function

`

//SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

contract MyContract{

string value;
constructor() public   {
    value = "MyValue";
}
function get() public returns(string)  {
    return value;
}

function set(string memory _value) public  {
    value = _value;
}


}`

on function get i get an error as TypeError: Data location must be "memory" or "calldata" for return parameter in function, but none was given. i couldnt solve it because the "value" variable is already identified it doesn neew to be memoried

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

string is a reference type, so you need to specify its data location. In this case, the value is loaded from storage to memory, and then returned from the memory.

function get() public returns(string memory)  {
    return value;
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!