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

197
Vistas
ETH transaction value always 0

I am trying to use uniswap v3 to add swaps to my project. Everytime i call the function in my contract from the frontend the value is 0 ETH in metamask and only the fee is paid. I have attempted all the ways i can think of converting the input string into wei, gwei, hex and so on and its always 0 on the metamask transaction page.

function transferApprove(uint _amountIn, address _routerAddress) internal
    {
        TransferHelper.safeTransferFrom(
            ETH,
            msg.sender,
            address(this),
            _amountIn
        );

        TransferHelper.safeApprove(WETH9, _routerAddress, _amountIn);
    }

    function swapExactInputSingle(uint _amountIn)  external returns (uint amountOut)
    {
      require(_amountIn > 0, "cannot swap 0 ETH");
      emit value(_amountIn);
        transferApprove(_amountIn, UNISWAP_V3_ROUTER);

        ISwapRouter.ExactInputSingleParams memory params = ISwapRouter
            .ExactInputSingleParams({
                tokenIn: ETH,
                tokenOut: WETH9,
                fee: 3000,
                recipient: msg.sender,
                deadline: block.timestamp,
                amountIn: _amountIn,
                amountOutMinimum: 0,
                sqrtPriceLimitX96: 0
            });

        amountOut = uniswapRouter.exactInputSingle(params);
    }

/////JAVASCRIPT SECTION

const sendSwap = async () => {
try{
    if(!window.ethereum) return alert("Please install metamask");
    const parsedAmount = ethers.utils.parseUnits(amount, 18);
    const provider = new ethers.providers.Web3Provider(window.ethereum, "any")
    const signer = provider.getSigner()
    const swap = new ethers.Contract(SwapAddress.address, SwapAbi.abi, signer)
    
    const accounts = await ethereum.request({method:'eth_requestAccounts'})
    setCurrentAccount(accounts[0])
    setSwap(swap)

    console.log(parsedAmount)
    const transactionHash = await swap.swapExactInputSingle(parsedAmount)
    setIsLoading(true);
    await transactionHash.wait();
    setIsLoading(false);
    console.log({transactionHash});
} catch (error) {
    console.log(error);
}
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