Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

259
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda