Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

305
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda