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

153
Vistas
How to swap ETH with WETH using UniswapV2?

I'm trying to swap ETH for its equivalent in WETH using UniswapRouterV2 and ethers.js but I don't know what address to put in as ETH in the path array since it doesn't have one, so please let me know what I'm doing wrong.

    await this.uniswapRouter.swapETHForExactTokens(
        ethers.provider.getBalance(attacker.addres), // amountOut
        [0, this.weth.address], // path: what should it be instead of 0?
        attacker.address, // to
        (await ethers.provider.getBlock('latest').timestamp) * 2, // deadline
        {value: ethers.provider.getBalance(attacker.addres)} // msg.value
    )
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Just got it. It was so simple and the UniswapRouterV2 contract was not needed at all. One has to execute the deposit function of WETH contract and the contract gives ETH back. Something like this:

 await this.weth.connect(attacker).deposit({value: ethToWETHAmount})
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