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

304
Visualizações
Uncaught (in promise) Error: invalid address

how to fix this error when i call a smart contract function?

Uncaught (in promise) Error: invalid address (argument="address", value={"from":"0xaD1D30B476C195C23ef4CC9b7A3c53E7423B7690"}, code=INVALID_ARGUMENT, version=address/5.0.5) (argument="index", value={"from":"0xaD1D30B476C195C23ef4CC9b7A3c53E7423B7690"}, code=INVALID_ARGUMENT, version=abi/5.0.7)

it's my code:

enter: async function() {
    App.contracts["MyContract"].deployed().then(async(instance) =>{
      var a = web3.eth.getAccounts();
      let ticketsForPlayers  = await instance.getTicketsForPlayers({from: App.account});
      console.log(ticketsForPlayers);
    });
  }
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

The Problem

The error shows that you didn't set the address property correctly, it's may be the issue with your solidity implementation and it's not related to javascript snippet, as mentioned in the comments, you can ask about it on related sites, but there are some points with the above snippet that may help you. you are mixing two different implementations in enter method to handle a promise which is clearly incorrect and leads to the issues.

The Points

use async/await with try/catch block. more on MDN documentation:

enter: async function () {
  try {
    const instance = await App.contracts["MyContract"].deployed()
    
    const properNameForVariable = web3.eth.getAccounts();

    const ticketsForPlayers = await instance.getTicketsForPlayers({from: App.account})

    console.log(ticketsForPlayers)
  } catch (error) {
    // do a proper action on failure cases
  }
}

Now, if there are errors in your async actions, it catches by catch block, you may also use console.error(error) or console.warn(error) in the catch block to see the exception and stack traces.

Note: using this approach with try/catch will ensure the application continues to work even after exceptions and errors.

about 4 years ago · Juan Pablo Isaza Relatório

0

using an old version of web3 for a tutorial web3@0.20.6 and Firefox 100.0.1

this was what I added to react to get resolve the error

web3.eth.defaultAccount = web3.eth.accounts[0]

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