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

69
Visualizações
Return address function from smart contract returns promise object instead of address in truffle test

Hi I have an address return function that works in remix but when I try to run it in a truffle test it gives me a promise object.

If I could have the truffle test return an address like it does in the solidity code that would be ideal or if I can access the promise object to give me my address. I have tried to add ".toString()" to the promise object but it does not give me the address

This is how I am trying to call the return function and save it to a variable within the truffle test

const newFractionContractAddress = await mainContract.getFractionContractAddress(0, {from: accounts[0]});

the solidity return function looks like this

function getFractionContractAddress(uint _index) public view returns(address) {
    return address(nftDeposits[msg.sender].deposits[_index].fractionContract);
}

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Sending EVM transactions and waiting for the result of how they're processed is, by design, asynchronous. JavaScript uses Promises to be able to handle asynchronous operations.

The Promise resolves to a string representing the address, which you are correctly retrieving using the await keyword.

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