Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

50
Vistas
Web3 .send() method promise remains <pending>

I'm working on a DAPP that connects to a smart contract through Web3 and MetaMask. I'm calling a claim method on the contract as follows:

try {
    const claimRes = await batchClaimTokenRewards(tokensArray, weeksArray);
    console.log('claim response: ', claimRes);
    this.getNftDataFromContract();
} catch(error) {
    console.log('claim error: ', error);
}

The batchClaimTokenRewards function is imported from another file, here's that function as well:

export async function batchClaimTokenRewards(tokensArray:string[], weeksArray:string[]) {
  return distributionContract.methods.batchClaimTokenRewards(tokensArray, [weeksArray]).send({from: web3.utils.toChecksumAddress('<metamask address>')});
}

From my understanding, the .send() method called on the contract instance should return a promise, which I should be able to await, however, the line where I'm trying to console.log claimRes is never reached, even as MetaMask shows the transaction as completed. The catch() expression is never reached either. When I log claimRes without using await on the promise, I get a <pending> promise in the Chrome console that remains in the <pending> state and never gets resolved, again, even as MetaMask itself reports the transaction as completed. What can I do to reliably get confirmation of a completed transaction?

7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.