Closed santanaruben closed 3 years ago
The mistake was to declare the deadline
outside the function that calls swapExactETHForTokens
, so it was set according to the time the contract was deployed.
If a time variable needs to be used according to actual parameters at run time, then it is necessary to declare it or set it at the time of use. Silly mistake, but important after all.
Hello friends, I am having a hard time creating a contract that uses the
swapExactETHForTokens
function.I intend to create a contract that receives ETH and then any user can swap those ETH for a specific token whose recipient is the same contract. Freezing those tokens (A token burning contract).
I'm using something like this, following the uniswap docs as a guide:
So far so good, I set a deadline of let's say 30 minutes, and I can make those swaps without any problem, however, when those 30 minutes of the first swap are reached, the contract does not allow me to make any other swap, sending me the error:
Fail with error 'UniswapV2Router: EXPIRED'.
It doesn't matter if I exceed the gas limit and the gas price. I always get that error.
This is one of the failed transactions of one of the instances https://kovan.etherscan.io/tx/0x446ab53eb290c9f5a40b34944c3dcb960843bef55a7a4fc00302270823c17bcc
Am I doing something wrong?