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

150
Visualizações
getting /u0000 when using web3js

I have tests 100% working and returning values but when I try and read the data using the web3 api in javascript for the homework i retrieve a return value of /u0000 for name and symbol, I'm not sure why.

Result

0: ""
1: "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
name: ""
symbol: "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
[[Prototype]]: Object

JS

  lookUp: async function (){
    const { lookUptokenIdToStarInfo } = this.meta.methods;
    const id = document.getElementById("lookid").value;
    var star = await lookUptokenIdToStarInfo(id).call();
    console.log(star)
    console.log(JSON.stringify(star));
    App.setStatus("star info is name:" + star.name + " symbol:" +   
    star.symbol + ".");
  }

Solidity

function lookUptokenIdToStarInfo (uint _tokenId) public view returns 
        (string memory name, string memory symbol) {
        //Solidity 0.8.0 and above can return our Star struct but to 
        be pure to previous standard way of doing things we are 
        returning it as a string
        name = tokenIdToStarInfo[_tokenId].name;
        symbol = tokenIdToStarInfo[_tokenId].symbol;
        return (name,symbol);
    }

Test

it('lookUptokenIdToStarInfo test', async() => {
    let tokenId = 7;
    let instance = await StarNotary.deployed();
    await instance.createStar('Awesome Star!', "AS", tokenId, {from: accounts[0]})
    var getByTokenId = await instance.lookUptokenIdToStarInfo(tokenId); 
    assert.equal(await getByTokenId.name, 'Awesome Star!')
    assert.equal(await getByTokenId.symbol, 'AS')
});
about 4 years ago · Juan Pablo Isaza
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