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

159
Visualizações
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 Respostas
Responde à pergunta

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 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