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

156
Vistas
Why does balanceOf return 0 sometimes after a swap?

I might be misunderstanding something about the way the EVM works, but I am running a script that conducts a tokenswap using the uniswap sdk and then logs the balances of the 2 tokens after the fact in a database/to the console. Intermittently the balanceOf function of the ERC20 contract will return 0 after the swap even though it's successful and I can see on the explorer the balance is not 0.

The way I understand it, once the transfer event is emitted in the swap and the transaction is mined (I am awaiting this), the balance should be updated for the address.

Sample code below:

const swapTx = await routerContract.swapExactTokensForTokens(...params.args);
const swapReceipt = await swapTx.wait();
const token1Bal = await token1Contract.balanceOf(myAddress);
const token2Bal = await token2Contract.balanceOf(myAddress);
console.log(token1Bal); //should be 0
console.log(token2Bal); //should not be 0, but sometimes is returning as 0???

Thanks.

about 4 years 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 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