swapETHForExactTokens

This method swaps an amount of ether for an exact amount of ERC20 tokens (_token1).

Function

function swapETHForExactTokens(
    address _to,
    address _token,
    uint _amountOut,
    uint _deadline
  ) external payable returns (uint input);

Parameters

ParameterDescription

_to

The address of the recipient.

_token1

An ERC20 token address.

_amountOut

The amount of _token1 that the user accepts for a given amount of ether.

_deadline

The UTC timestamp that if reached, causes the swap transaction to fail automatically

Return values

ValueDescription

uint _val

The amount of _token0.

Last updated